This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Uppercase to lowercase URL’s
Author
Message |
ianhoughton
Newbie


Joined: 16 September 2010
Posts: 3
Posted: 16 September 2010 at 3:16am

I'm trying to remove any uppercase characters from the incoming
URL's as well add www to non-www addresses.

So far I have non-www addresses working with this code:

RewriteEngine on

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

I now need to implement the uppercase to lowercase code. I've
tried the following:

RewriteCond Host: (.*)
RewriteRule ([^?]*[A-Z].*) http\://$1$2 [RP,CL]

this works, but only returns the page name i.e contact.aspx
without the domain name. If I change the code to this:

RewriteCond Host: (.*)
RewriteRule ([^?]*[A-Z].*) http\://www.domain.co.uk/$1$2 [RP,CL]

then the uppercase to lowercase change does not work.
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 16 September 2010 at 4:12am

It looks like you are actually using ISAPI_Rewrite v3, so your rules should be like this:

RewriteCond %{HTTP_HOST} (.*)
RewriteRule ([^?]*[A-Z].*) http\://%1$1 [R+301,CL,L]

__________________
Regards,
Anton
Back to Top
 
ianhoughton
Newbie


Joined: 16 September 2010
Posts: 3
Posted: 16 September 2010 at 4:33am

That's getting close !!!

Using your code the URL gets changed from:

http://www.domain.co.uk/ABout.aspx
to
http://www.domain.co.ukabout.aspx

We're just missing the slash between uk & about.

I tried adding a slash between %1 & $1. This corrected the
issue but then the uppercase characters didnt change.
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 16 September 2010 at 7:30am

Let's try to have the entire config like this:

RewriteEngine on
RewriteBase
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

RewriteCond %{HTTP_HOST} (.*)
RewriteRule ^(.*[A-Z].*)$ http\://%1$1 [R=301,CL,L]

If it doesn't work as expected, please enable logging in httpd.conf and provide rewrite log records for the testing request.

__________________
Regards,
Anton
Back to Top
 
ianhoughton
Newbie


Joined: 16 September 2010
Posts: 3
Posted: 16 September 2010 at 8:11am

Thanks, that works a treat !!!
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version
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 cannot vote in polls in this forum