2

I have been experiencing a problem yesterday. My site is in Hebrew language. MY site is built on Wordpress. The problem is related to escaped encoded posts URL only. IF the post URL has escaped encode in uppercase it works, if in lowercase, it returns 404. I want both to pass without a problem. I am hosting my site on godaddy shared hosting. Is there any option to let both uppercase and lowercase be accepted and show the same post?

For example: http://domain.com/%d7%9e%d7%a6%d7%9c%d7%9e%d7%95%d7%aa/ (this is what my site have)

Google crawled it as: http://domain.com/%D7%9E%D7%a6%D7%9C%D7%9E%D7%95%D7%AA/ (this returned 404)

I think that in the mod_rewrite (htaccess) I should make the URL transfered to wordpress as a non-case sensitive. How can I do that?

Liron Harel
  • 431
  • 1
  • 4
  • 13

1 Answers1

2

Based on your example URL, you want URLs escaped in lowercase, If you have control over your server or virtual host, you can define a tolower map and use it in your rewrite rules as below:

RewriteEngine On
RewriteMap  tolower int:tolower
RewriteCond %{REQUEST_URI} [a-z]
RewriteRule (.*) ${tolower:$1} [R=301,L]

You can also complete and use the following code in yout htaccess:

Options +FollowSymLinks
RewriteEngine on
# If the URI does not contain any uppercase letters, skip the next 28 rules.
RewriteRule ![A-Z] - [S=28]
#
# Else convert the first instance of "A" to "a", "B" to "b", etc.
RewriteRule ([^A]*)A(.*) $1a$2
RewriteRule ([^B]*)B(.*) $1b$2
# <22 more rules>
RewriteRule ([^Y]*)Y(.*) $1y$2
RewriteRule ([^Z]*)Z(.*) $1z$2
#
# If any more uppercase characters remain, restart mod_rewrite from the top
RewriteRule [A-Z] - [PT,N]
# Otherwise do an external 301 redirect to give the client the new URL.
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# Skip to here if no uppercase letters in client-requested URL.
# <some other rules>

If you don't have control over server , you can also use a wordpress redirection plugin to convert all incoming URLs to lowercase. ( s/[A-Z]/\l&/g )

http://wordpress.org/extend/plugins/permalowercase301/

Another solution is to change your 404 error page to detect such links and redirecting them.

http://www.unfocus.com/2007/08/31/case-insensitive-permalinks-plugin-for-wordpress/

Reza Hashemi
  • 266
  • 2
  • 5
  • many thanks, but can you make the same example for lowercase to uppercase. – Liron Harel Sep 07 '11 at 14:12
  • that would be easy. just swap A-Z with a-z and also A with a and go on with other letters, also tolower to toupper, e.g. RewriteRule ([^A]*)A(.*) $1a$2 becomes RewriteRule ([^a]*)a(.*) $1A$2 and RewriteRule ![A-Z] - [S=28] becomes RewriteRule ![a-z] - [S=28] and RewriteMap tolower int:tolower becomes RewriteMap toupper int:toupper – Reza Hashemi Sep 10 '11 at 15:35