File Ending Problem

Discuss practical ways rearrange URLs using mod_rewrite.

File Ending Problem

Postby sharingsunshine » Mon Aug 25, 2008 3:14 pm

Hello,

I am needing to create a rewrite for the following file endings to all change to .html files.

1.example.htlm
2.example.htm
3.example.HTML

All of the above examples need to change to example.html

Here is what I created but it won't work. Looking at the examples I have seen it seems like it should work.

Options +SymlinksIfOwnerMatch -Indexes -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(.+)\.(htlm|htm|HTML)
RewriteRule ^.+$ /%1.html [L,R=301]

Please help me to get this working.

Thanks,


Randal
sharingsunshine
 
Posts: 55
Joined: Tue Dec 19, 2006 5:32 am

Postby richardk » Tue Aug 26, 2008 11:11 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Make sure it's not lowercase .html.
RewriteCond %{REQUEST_URI} !\.html$
# Match any case of HTML, HTM or HTLM.
RewriteRule ^(.+\.)(html?|htlm)$ /$1html [NC,R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sharingsunshine » Wed Aug 27, 2008 7:51 am

Thanks a lot. That works just great!

Randal
sharingsunshine
 
Posts: 55
Joined: Tue Dec 19, 2006 5:32 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 13 guests

cron