views:

206

answers:

2

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]
A: 

I only see the chance to combine the latter two:

RedirectRule ^/([^A-Z?]*[A-Z].*(/|\.html|\.aspx))$  /#L$1#E [R=301]
RedirectRule ^/([^.?]+?[^.?/])(/index\.html)?$ /$1/ [I,R=301]
Gumbo
A: 

There's an excellent answer to this question on the IIRF Forums.

Cheeso