Forum Moderators: phranque

Message Too Old, No Replies

Redirect links that have capital letters

         

BigFan11

9:09 pm on May 10, 2011 (gmt 0)

10+ Year Member



I am trying to 301 direct any links that have capital letters. I am using Helicon ISAPI_Rewrite3. I've searched about the topic and ended up having these three lines in my .htaccess file:
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^/(.*)$ /${lc:$1} [R=301,L]

One link said that the first line shouldn't be on the .htaccess. I've tried moving it to the httpd.conf file, but no change.

I still can't get it to redirect to the link with the lowercase. I want this link: [mysite...] to be directed to [mysite...]

Not only that. I want to make sure that it indeed directed. I used this link to verify the status of a link: [seoconsultants.com...]

I am following the steps that the comment #15 mentioned in this link:
[chrisabernethy.com...]

What did I miss?

Please help,

thank you!

g1smd

9:14 pm on May 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I usually install a hook inside .htaccess that detects upper case requests which are then rewritten to a special PHP script. The PHP script then fixes the URL format and sends the redirect response.

The code was posted in full in this forum only a week or so ago in [webmasterworld.com...]

BigFan11

7:46 pm on May 11, 2011 (gmt 0)

10+ Year Member



Is there any .aspnet solution? (I am using IIS 6.0)

BigFan11

2:49 pm on May 13, 2011 (gmt 0)

10+ Year Member



I have figured it out!
The solution was working for me the whole time.

all I had to do was clearing the cache on my machine to make the pages load fine. Get this, I was not able to even call pages that I have not before.
I was going nut. Luckily, after I figured it out, I had to do it for other sites, so I did a screen recording of the behavior and the fix (the clearing of all files/cache and cookies). i was able to replicate the issue, the fix over and over again!

BigFan11

9:06 pm on May 13, 2011 (gmt 0)

10+ Year Member



After figuring it out, i am still a bit unclear about what the real cause of the issue was. Maybe someone here can help me understand this.
I will mention the symptom and the sure fix that did it everytime in chronological order:
1. I request couple of pages of a site. The pages load normally.
2. Add .htaccess that has a single rule to redirect uppercase url to lower ones.
3. request the same pages from #1. All three break. The css is not in place.
4. Restart the IIS server (in my previous update, I had an alternate solution where I would fix it by clearing all my cookies, cache files and history on my browser, but restarting the IIS is easier).
5. Reload the pages... load fine!

I did this on at least 7 sites. The same exact behavior kept happening... every single time! I am so sure of this sequence.

Here is the single rule that I had in my .htaccess:
*******************************
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteRule ^(.*[A-Z].*)$ $1 [R=301,CL,L]
*******************************

how did the .htaccess affect the css and how did it get fixed because of the restart of the IIS?

Any ideas of what was happening? Guesses are welcome too.

g1smd

9:58 pm on May 13, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I assume the CL flag converts everything to lower case?

BigFan11

2:12 pm on May 16, 2011 (gmt 0)

10+ Year Member



yes, the CL converts everything to lower case. Do you know what was happening with the css?