URL – Case Sensitive URL Rewrites

urlurl-rewrite

I wish to create a series of rewrites so that the following redirect occurs:

Request: Category/ProductName.html
Target: category/productname.html

At present, visiting Category/ProductName.html renders a 404. When I try to create a URL rewrite to this, I get 'Request Path for Specified Store already exists.' and I think it's because of the casing.

Does anyone know a way around this?
These really need to be 301 redirects as they're from the old system, they're being transferred over to the new one and we can't have lots of 404s around the site because of a casing issue.

Best Answer

A huge amount of digging and I've found a single, tiny fix to get this to work.

Essentially, this is a drawback of MySQL as a data medium. MySQL is typically case insensitive. The field that stores the request paths has a 'UNIQUE' constraint upon it, meaning it can only store one of the below:

Category/ProductName.html
Category/productname.html

It treats both items the same, so the UNIQUE key disallows the second one, due to the presence of the first.

What I was able to do was change the COLLATION of the request_path field in the core_url_rewrite table from utf8 (the table default) to utf8_bin which makes it case sensitive.

Related Topic