[thelist] htaccess problem

Phil Turmel philip at turmel.org
Tue Nov 16 14:26:32 CST 2010


Hi Alex,

On 11/16/2010 11:09 AM, Alex Beston wrote:
> hi Evolt
> 
> If I have:
> 
> http://www.example.com/folder/page.shtml
> 
> how do I convert it to -
> 
> http://www.example.com/folder/page/

Is this a permanent change?  The originals no longer exist (or won't, when you're done)?

> (also -
> 
> http://www.example.com/folder/index.shtml
> 
> should go to:
> 
> http://www.example.com/folder/
> 
> and lastly, subdirectories -
> 
> http://www.example.com/folder/sub_folder/file.shtml
> 
> translates to:
> 
> http://www.example.com/folder/sub_folder/file/
> 
> hope thats clear!)

I suspect you need something like this to handle all of the cases above:

RewriteRule ^/(.+)/index.shtml /$1/ [R=301]
RewriteRule ^/(.+).shtml /$1/ [R=301]

This won't match

http://www.example.com/index.shtml

but will match

http://www.example.com/page.shtml
http://www.example.com/folder/index.shtml
http://www.example.com/really/deep/path/page.shtml

and convert them to

http://www.example.com/page/
http://www.example.com/folder/
http://www.example.com/really/deep/path/page/


HTH,

Phil


More information about the thelist mailing list