Forum Moderators: phranque
Recently we noticed that our urls are case-insensitive.
As mentioned here: brianflove.com/2014/08/11/lowercase-your-uris)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${lc:$1} [R=301,L]
You would need to remove the ! (negation) prefix on the CondPattern of the first 2 conditions (RewriteCond directives), so that only files that exist are rewritten.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
...some of these old urls have uppercase letters in them. Do you think that the above mentioned redirect rule will contradict with these manually set redirects in some way?
We also want to do few other 301 redirects on our site to undo editorial errors in past and some of these old urls have uppercase letters in them. Do you think that the above mentioned redirect rule will contradict with these manually set redirects in some way?
RewriteRule [A-Z] blahblah
(no anchors) meaning "If the request contains EVEN ONE capital letter in the path, then do stuff". The "stuff" can be either the to_lower RewriteMap (if you've got access to the config file, which it sounds as if you do) or a php page (if you don't).
RewriteRule [A-Z] blahblah
RewriteCond %{REQUEST_URI} .*
RewriteRule .* - [E=ENV_MATCHED_CASE_TEST:$0\ %0]
<?php
echo getenv('ENV_MATCHED_CASE_TEST');
This is presumably for URLs that map directly to the filesystem?
Assuming the actual file on the file system is "example.html"
Are you redirecting to another URL that contains uppercase letters?
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
4) www canonicalization redirectThese two can be combined into a single rule. Use two Conditions, with [OR].
5) https canonicalization redirect
Do we have to use https protocol in lowercase redirection rule as well?Use the correct protocol for each individual URL. If necessary, have two sets of rules-- one for the HTTP directories and the other for HTTPS.
I am not sure, what actual name the file gets when an editor creates a page in backend and names it as '/Sample-Page'. How do I check it? What if its also a, 'Sample-Page'.