3

On a website there is folder products/ and inside are php files with some Uppercase characters.

Example: www.example.com/products/BIT-Defendar.php

Now this urls exist for years and all around search engines. It was a mistake from the product manager.

But I want to fix this i want only lowercase URL's.

Will this fix my issue? CheckSpelling On CheckCaseOnly On (1)

And whats different with mentioned above and: (2)

RewriteMap tolowercase int:tolower 
RewriteRule ^(.*)$ ${tolowercase:$1}

If I use (1) then all works wither I request url lower cased or upper-cased (but will I have search engine problems?)

If I use (2) I have to rename all files inside of products/ folder to lowercase.

---- EDIT ----

When i use RewriteRule i get transferred to domain root if url is uppercase, if i use CheckSpelling and CheckCaseOnly then all fine.

I have tested with this and i get:

RewriteCond %{REQUEST_URI} [A-Z]    

- This condition was met

RewriteRule (.*) ${tolowercase:$1} [R=301,L]    

- This rule was met, the new url is http://www.example.com/${tolowercase:products/BIT-Defendar.php}

- Test are stopped, because of the R in your RewriteRule options. A redirect will be made with status code 301

My setup in httpd.conf:

<VirtualHost *:80>
 RewriteMap tolowercase int:tolower
</VirtualHost>
FeRtoll
  • 1,247
  • 11
  • 26
  • You probably need to redirect users to lower case URLs instead of rewriting. Search engines can see redirects, not rewrites. – Salman A Nov 30 '12 at 19:53
  • When i use *RewriteRule* i get transfered to domain root if url is upercased, if i use *CheckSpelling* and *CheckCaseOnly* then all fine. – FeRtoll Nov 30 '12 at 23:36

1 Answers1

3

Using the CheckSpelling and/or CheckCaseOnly directive may cause undesired results, as mentioned at the bottom here:

1, performance issues
2, some files might be skipped
3, some files might be misinterpreted

I would think it unwise to allow apache make the corrections for you, as you rely on apache to search directories and files for every single look up, whereas with the lowercase map, it puts you in full control and just creates strict standards.

I would recommend adding a flag [R=301] which will inform search engines that this is the new file, and you won't have any search engine related issues:

RewriteMap tolowercase int:tolower 
RewriteRule ^(.*)$ ${tolowercase:$1} [R=301,L]

You would have to rename your files, as they will no longer be recognized, but you can write a simple script to scan all files, and rename them as lowercase.

Samuel Cook
  • 16,620
  • 7
  • 50
  • 62
  • I don't understand on what *undesired results* you refer to. If you think on line where it mentions *DAV enabled directories* i don't use that. – FeRtoll Nov 30 '12 at 19:18
  • Problem is: using this rewrite i get redirected to homepage when url(www.example.com/products/NEW-defender.php) is upper-cased – FeRtoll Nov 30 '12 at 22:07
  • your code crashed my entire site for a second til i removed it – Michael d Nov 08 '15 at 17:28