PDA

View Full Version : removing .htm from URL


dynankaan
12-19-2010, 07:04 PM
Hello

My question is:
Is there any way i could "delete" the ending (.htm) of the pagefile so i can type site url in the browser without (.htm) but still reach the same page?
Here is an example:
This is how the url looks like today: http://www.mysite.com/page.htm
And i would like to delete (.htm), like this: http://www.mysite.com/page

Meta tags? i cant figure it out :(, i really need your help!

Thank you, Dynankaan

gentleone
12-19-2010, 07:59 PM
You can do this with .htaccess if your webserver is running on Apache.

DWcourse
12-19-2010, 07:59 PM
Generally index.html is the default file name for any folder so

http://www.mysite.com/page/index.html and http://www.mysite.com/page would point to the same page.

You could also insert a 301 redirect in your htaccess file (if you know what that is).

Finally a lot of urls like that are the result of using a content management system (CMS) sucha s WordPress, Joomla, etc.

gentleone
12-19-2010, 08:10 PM
Add the following to your .htaccess file, upload it to your server and you have what you want.

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.htm [L]
If you don't have a .htaccess file yet, you can create one with NotePad (pc) or TextEdit (mac). Paste the above in a new text file and save it as htaccess.txt. Upload it to your server and rename it on your server to .htaccess and you're done.

dynankaan
12-19-2010, 09:44 PM
Add the following to your .htaccess file, upload it to your server and you have what you want.

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.htm [L]
If you don't have a .htaccess file yet, you can create one with NotePad (pc) or TextEdit (mac). Paste the above in a new text file and save it as htaccess.txt. Upload it to your server and rename it on your server to .htaccess and you're done.


Thanks everyone for helping me!!!

I have one problem... When i upload it to my server (webhotel) i cant reach my site, it says:
The page cannot be displayed There is a problem with the page you are trying to reach and it cannot be displayed. It is most likely that configuration files for this url are corrupted.


Do you know what the problem is?

Thank you, Dynankaan

gentleone
12-20-2010, 06:33 AM
It might be that you'll have to enable mod_rewrite on your server. Most servers has this enabled by default, but some don't. Put this line at the top of your .htaccess file (so above RewriteEngine on).
Options +FollowSymLinks

dynankaan
01-09-2011, 12:05 PM
sorry guys, ive been very busy, i'll try to insert:
Options +FollowSymLinks
i hope this code work!! i will keep you updated.

dynankaan
05-06-2011, 12:15 AM
sorry guys, ive been very busy, i'll try to insert:
Options +FollowSymLinks
i hope this code work!! i will keep you updated.

Sorry guys, this is not working for me :(

The Text in my .htaccess file is the following:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.htm [L]

should i ad or change something in the text? or how do i get this working?

Cheers!!

gentleone
05-09-2011, 12:38 PM
That piece of code should be working, so I'm not sure why it's not working for you.

You could ask your host for assistance, because I'm out of guesses.

Corrosive
05-09-2011, 03:01 PM
Are you definitely on the right hosting Linux/Apache?

gentleone
05-09-2011, 05:29 PM
Are you definitely on the right hosting Linux/Apache?
Ahum... that's indeed a good question!