HighDots Forums  

.htaccess - htm / html question

alt.html alt.html


Discuss .htaccess - htm / html question in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nllamas
 
Posts: n/a

Default .htaccess - htm / html question - 04-01-2006 , 04:49 PM






Hi folks,

Checking my error logs, today, I find that some people are occasionally
requesting pages with an .htm extension rather than .html
Not sure why this is - all my pages have always ended in .html.

Anyway, is there something I can put in my .htaccess file to direct requests
for .htm pages to the correct .html file.
I know I can use a redirect for each individual page (such as:
RedirectPermanent /somepage.htm http://www.example.com/somepage.html )
but I was hoping for something simpler, so I don't have to list every page
individually.

Thanks!
nllamas



Reply With Quote
  #2  
Old   
Steven
 
Posts: n/a

Default Re: .htaccess - htm / html question - 04-01-2006 , 05:05 PM






On Sat, 01 Apr 2006 21:49:21 GMT, "nllamas" <nospam (AT) hotmail (DOT) com> wrote:

Quote:
Checking my error logs, today, I find that some people are occasionally
requesting pages with an .htm extension rather than .html
Not sure why this is - all my pages have always ended in .html.

Anyway, is there something I can put in my .htaccess file to direct requests
for .htm pages to the correct .html file.
I think RewriteCond and RewriteRule will do what you want but offhand I
can't say exactly what to put in .htaccess as I haven't done it.

Here is an example from one of my directories :

# If no filename, use index.htm
# If file missing, redirect (permanent) to Exetel

RewriteEngine on
RewriteRule ^$ index.htm [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ http://home.exetel.com.au/phelum/$1 [R=301,L]

I referred to the documentation at httpd.apache.org. Hopefully there
will be an example there for what you want.

--
Steven


Reply With Quote
  #3  
Old   
Jim Higson
 
Posts: n/a

Default Re: .htaccess - htm / html question - 04-01-2006 , 05:19 PM



nllamas wrote:

Quote:
Hi folks,

Checking my error logs, today, I find that some people are occasionally
requesting pages with an .htm extension rather than .html
Not sure why this is - all my pages have always ended in .html.

Anyway, is there something I can put in my .htaccess file to direct
requests for .htm pages to the correct .html file.
I know I can use a redirect for each individual page (such as:
RedirectPermanent /somepage.htm http://www.example.com/somepage.html )
but I was hoping for something simpler, so I don't have to list every page
individually.
Try http://httpd.apache.org/docs/2.0/misc/rewriteguide.html


Reply With Quote
  #4  
Old   
nllamas
 
Posts: n/a

Default Re: .htaccess - htm / html question - 04-01-2006 , 05:19 PM



"Steven" <Phelum (AT) Syd (DOT) au> wrote

Quote:
On Sat, 01 Apr 2006 21:49:21 GMT, "nllamas" <nospam (AT) hotmail (DOT) com> wrote:

Checking my error logs, today, I find that some people are occasionally
requesting pages with an .htm extension rather than .html
Not sure why this is - all my pages have always ended in .html.

Anyway, is there something I can put in my .htaccess file to direct
requests
for .htm pages to the correct .html file.

I think RewriteCond and RewriteRule will do what you want but offhand I
can't say exactly what to put in .htaccess as I haven't done it.

Here is an example from one of my directories :

# If no filename, use index.htm
# If file missing, redirect (permanent) to Exetel

RewriteEngine on
RewriteRule ^$ index.htm [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ http://home.exetel.com.au/phelum/$1 [R=301,L]

I referred to the documentation at httpd.apache.org. Hopefully there
will be an example there for what you want.

--
Steven
Thanks Steven!
I followed your suggestion and after a bit of hunting around I found:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.htm$ $1.html [R=permanent]

and it does just the trick.

Thanks again!
nllamas




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.