IIRF redirect combine rules?

Posted by Phill on Stack Overflow See other posts from Stack Overflow or by Phill
Published on 2009-11-18T22:03:33Z Indexed on 2010/04/04 4:23 UTC
Read the original article Hit count: 746

Filed under:
|
|
|

I have 3 "rules". One to make sure URLs are lowercase another to include a slash at the end of directories, and a 3rd to force access to index.html pages to be thru the directory instead.

The problem w/ how I have it is, sometimes this is causing multiple 301 redirects. I'd really like each rule to apply in turn and then if neccessary redirect once to the final url. For example a url might need to be converted to lowercase and have a slash added. Or may need to be lowecase and change from index.html to a directory.

Any ideas how I can do this? Thanks very much.

The rules are below:

#LOWERCASE URLS For Directories, aspx, html files
RedirectRule ^/(.*[A-Z].*(/|\.html|\.aspx))$  /#L$1#E [R=301]


#ADD SLASH TO DIRECTORIES
#---------------------------------------------
#Perm Redirect If:
#Starts w/ Forward Slash
#Match Any Characters Except (. or ?) 1 or more times
#End w/ someting besides a dot, ?, or slash
#If So, Perm Redirect captured piece W/ Slash At End and at front
RedirectRule ^/([^.?]+[^.?/])$ /$1/  [I,R=301]


#CHANGE INDEX.HTML REQUESTS TO DIRECTORY REQUESTS
#---------------------------------------------
RedirectRule ^/(.*)/index\.html$ /$1/  [I,R=301]

© Stack Overflow or respective owner

Related posts about mod-rewrite

Related posts about url