How to canonicalise case?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 92
Joined: 01 Dec 2012, 14:22

How to canonicalise case?

08 Nov 2013, 00:30

Due to a faulty sitemap some time back, there are some variants of URLs out in the wild.

Google penalises URLs with the same meta-tags, even if the URLs differ only in case (which is a pain, because some idiot could type one in wrongly, or link to it), and IIS doesn't care.

E.g. if we have "marquees-in-yorkshire.html" as a valid URL, and there's also "Marquees-in-Yorkshire.html" out there, they will both call the same URL, and Google will say you have duplicate meta descriptions.

So- I thought, let's have a rewritemap for the known bad ones.

So I constructed seofix.map, containing e.g.

/Marquees-in-Yorkshire.html /marquees-in-yorkshire.html

And added the following code into .htaccess:

#Rewrite Duplicated SEO names with a rewritemap
RewriteMap seofix txt:seofix.map
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ${seofix:%{REQUEST_URI}|NOT_FOUND} !NOT_FOUND
RewriteRule (.*\.html) ${seofix:%{REQUEST_URI}} [L,NS,R=302,QSA]

- omitting the usual [NC] flag, so that it *will* be case-sensitive.

However, if you *do* this, it says you have a rewrite loop! Presumably because IIS doesn't care about case.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: How to canonicalise case?

08 Nov 2013, 11:30

Long time no see )

I'm afraid you're overcomplicating things. Take a look here - http://www.helicontech.com/isapi_rewrit ... teRule.htm - CL-flag.

If you put a rule on top of your file it will automatically lowercase everything and no idiot will spoil your google renking.

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 15 guests