This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Combine Trailing Slash and Lowercase URLs Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
billr578
Newbie
Newbie


Joined: 17 August 2006
Location: United States
Online Status: Offline
Posts: 28
Posted: 01 February 2012 at 3:18pm | IP Logged Quote billr578

Hi,

I have two rewrite conditions to handle for a missing
slash on all URLs as well as making sure all of our URLs
are redirected to the lowercase version:

# Fix missing slash on folders
RewriteCond %{HTTP:Host} (.*)
RewriteRule ^([^.?]+[^.?/])(\?.*)?$ http\://%1$1/$2
[NC,R=301]

# We want all lowercase URLs
RewriteCond %{REQUEST_URI} !\.
(?:axd|asmx|aspx|jpg|gif|png|css|js)
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule .? %{REQUEST_URI} [CL,R=301,L]

One problem we're noticing is that with two separate
URLs, you could end up with multiple 301 redirects, i.e.
no trailing slash AND upper case characters in the URL.

My question is, is there an easy way to combine all of
this into one rewrite condition to handle all cases while
only doing one 301 redirect?

Any assistance (or even a solution) is GREATLY
appreciated. Thanks in advance!

Regards,
Bill Rowell
http://www.billrowell.com/
Back to Top View billr578's Profile Search for other posts by billr578 Visit billr578's Homepage
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 03 February 2012 at 7:26am | IP Logged Quote Guests

Hello Bill,

Try using the following rule:

# Fix missing slash on folders
RewriteCond %{HTTP:Host} (.*)
RewriteRule ^([^.?]+[^.?/])(\?.*)?$ http\://%1$1/$2 [NC,CL,R=301]


Regards
Andrew

Back to Top View Guests's Profile Search for other posts by Guests
 
billr578
Newbie
Newbie


Joined: 17 August 2006
Location: United States
Online Status: Offline
Posts: 28
Posted: 03 February 2012 at 9:20am | IP Logged Quote billr578

Hi Andrew,

Unfortunately that didn't work. It fixed the trailing
slash, but would not redirect to an all lowercase URL. I
think a combination of both of the rewrites I'm using now
is necessary, I just can't get it to work properly.

Regards,
Bill Rowell
http://www.billrowell.com/
Back to Top View billr578's Profile Search for other posts by billr578 Visit billr578's Homepage
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 06 February 2012 at 5:53am | IP Logged Quote Guests

Lets take a look at how the request is processed.
Please, provide the rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
billr578
Newbie
Newbie


Joined: 17 August 2006
Location: United States
Online Status: Offline
Posts: 28
Posted: 06 February 2012 at 9:17am | IP Logged Quote billr578

I ended up using something like this based on your
suggestion and another thread:

# Fix missing slash on folders make all URLs lowercase
RewriteCond %{REQUEST_URI} !\.
(?:axd|asmx|aspx|jpg|gif|png|css|js) [NC]
RewriteRule ^([^.?]+[^.?/])$ $1/ [CL,R=301,L]

RewriteCond %{REQUEST_URI} !\.
(?:axd|asmx|aspx|jpg|gif|png|css|js)
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule .? %{REQUEST_URI} [CL,R=301,L]

So the top part works for all the cases EXCEPT when the
trailing slash is already there and there are uppercase
characters. So it will fall through to the second case.

Its probably not ideal, but its at least working.

-Bill
Back to Top View billr578's Profile Search for other posts by billr578 Visit billr578's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum