Hi
Hoping I’ve missed something obvious, but can’t to pinpoint it.
Our old cart used categories/product URL’s like this, both of which returned the same content without the 404 issues I’m having with CS-Cart:
domain.com/categories/Root-Category/Sub-Category
OR
domain.com/categories/root-category/sub-category
and
domain.com/products/Product-Name.html
OR
domain.com/categories/product-name.html
These both directed to one valid category/product page, regardless of the capitalisation (uppercase) character of each word.
Unfortunately in the old cart, the URL was generated automatically from the product name, so a product with a symbol character in the URL, would produce an ugly URL, such as a product called ‘Category - Name’ would produce:```php
http://www.domain.com/category/Category-%252d-Name/
CS-Cart strips these symbols out, therefore the product URL has become:<br />
```php
http://www.domain.com/categories/category-name/
```<br />
<br />
So, I have set 301 redirects up in .htaccess like so for the new category URL's:<br />
```php
<br />
redirect 301 /categories/Category-Name/ http://www.domain.com/category-name/
```<br />
<br />
This, for some bizarre reason, redirects to:<br />
```php
http://www.domain.com/Category-Name/?sef_rewrite=1
```<br />
Which produces a 404 error, but, why does it change to Uppercase and why is '?sef_rewrite=1' in there?<br />
<br />
In CS-Cart, pages only seem to be served with some dodgy hack shown below, so in this CS-Cart, to 'resolve' this, category and product URL's only seem to be served with some dodgy hack shown below.<br />
<br />
In index.php:<br />
```php
$url = $_SERVER['REQUEST_URI'];<br />
$pattern = '/([A-Z]+)/';<br />
<br />
if(preg_match($pattern, $url)) {<br />
$new_url = strtolower($url);<br />
<br />
Header( 'HTTP/1.1 301 Moved Permanently' );<br />
Header( 'Location: ' . $new_url );<br />
exit;<br />
}
```<br />
<br />
This forces Uppercase to Lowercase in the URL and therefore redirects the customer to the appropriate page. However, the code above seems a dirty way of doing it and I can't for the life of me figure out why the .htaccess isn't working properly.<br />
<br />
If I use a RewriteMatch function for redirecting /Categories/Category-Name/ by stripping 'Categories/', the page returns http://www.domain.com/?sef_rewrite=1<br />
<br />
Therefore the dirt index.php hack above seems to be the only solution, which appears to break other functions anyway.<br />
<br />
Here's the .htaccess, any clues? I know this is a looooong post, so if you've read it all, thanks for sticking with me!<br />
```php
<br />
DirectoryIndex index.html index.php<br />
<br />
<IfModule mod_rewrite.c><br />
<br />
RewriteEngine on<br />
<br />
# Some hostings require RewriteBase to be uncommented<br />
<br />
# Example:<br />
<br />
# Your store url is http://www.yourcompany.com/store/cscart<br />
<br />
# So "RewriteBase" should be:<br />
<br />
# RewriteBase /store/cscart <br />
<br />
# RewriteBase /<br />
<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
<br />
RewriteRule . index.php?sef_rewrite=1 [L,QSA]<br />
<br />
RewriteRule ^(.*\.(js|css))$ smartoptimizer/?$1<br />
<br />
</IfModule> <br />
<br />
<IfModule !mod_expires.c><br />
<br />
RewriteCond %{REQUEST_FILENAME} -f<br />
<br />
RewriteRule ^(.*\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt))$ smartoptimizer/?$1<br />
<br />
</IfModule><br />
<br />
<IfModule mod_expires.c><br />
<br />
<FilesMatch "\.(ico|gif|jpg|jpeg|png|swf|css|js|html?|xml|txt)$"><br />
<br />
ExpiresActive On<br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
</IfModule><br />
<br />
<IfModule mod_headers.c><br />
<br />
<FilesMatch \.(css|js)$><br />
<br />
Header append Vary User-Agent<br />
<br />
Header append Vary Accept-Encoding<br />
<br />
Header append Cache-Control private<br />
<br />
</FilesMatch><br />
<br />
<FilesMatch \.(bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt|eot|ttf|otf|svg)$><br />
<br />
Header append Cache-Control public<br />
<br />
</FilesMatch><br />
<br />
<FilesMatch \.(js|css|bmp|png|gif|jpe?g|ico|flv|wmv|asf|asx|wma|wax|wmx|wm|swf|pdf|doc|rtf|xls|ppt)$><br />
<br />
Header unset ETag<br />
<br />
FileETag None<br />
<br />
</FilesMatch><br />
<br />
</IfModule><br />
<br />
<br />
# Turn on Expires and set default to 0<br />
<br />
<IfModule mod_expires.c><br />
<br />
ExpiresActive On<br />
<br />
<FilesMatch \.css$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType text/css A315360000<br />
<br />
<FilesMatch \.js$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType text/javascript A315360000<br />
<br />
ExpiresByType application/javascript A315360000<br />
<br />
ExpiresByType application/x-javascript A315360000<br />
<br />
ExpiresByType text/x-js A315360000<br />
<br />
ExpiresByType text/ecmascript A315360000<br />
<br />
ExpiresByType application/ecmascript A315360000<br />
<br />
ExpiresByType text/vbscript A315360000<br />
<br />
ExpiresByType text/fluffscript A315360000<br />
<br />
<FilesMatch \.(bmp|png|gif|jpe?g|ico)$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType image/gif A315360000<br />
<br />
ExpiresByType image/png A315360000<br />
<br />
ExpiresByType image/jpeg A315360000<br />
<br />
ExpiresByType image/x-icon A315360000<br />
<br />
ExpiresByType image/bmp A315360000<br />
<br />
<FilesMatch \.(eot|ttf|otf|svg)$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType application/x-font-opentype A315360000<br />
<br />
ExpiresByType application/x-font-truetype A315360000<br />
<br />
ExpiresByType application/x-font-ttf A315360000<br />
<br />
ExpiresByType application/x-font A315360000<br />
<br />
ExpiresByType font/opentype A315360000<br />
<br />
ExpiresByType font/otf A315360000<br />
<br />
ExpiresByType application/vnd.oasis.opendocument.formula-template A315360000<br />
<br />
ExpiresByType image/svg+xml A315360000<br />
<br />
ExpiresByType application/vnd.ms-fontobject A315360000<br />
<br />
ExpiresByType font/woff A315360000<br />
<br />
<FilesMatch \.(flv|wmv|asf|asx|wma|wax|wmx|wm)$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType video/x-flv A315360000<br />
<br />
ExpiresByType video/x-ms-wmv A315360000<br />
<br />
ExpiresByType video/x-ms-asf A315360000<br />
<br />
ExpiresByType video/x-ms-asx A315360000<br />
<br />
ExpiresByType video/x-ms-wma A315360000<br />
<br />
ExpiresByType video/x-ms-wax A315360000<br />
<br />
ExpiresByType video/x-ms-wmx A315360000<br />
<br />
ExpiresByType video/x-ms-wm A315360000<br />
<br />
<FilesMatch \.(swf|pdf|doc|rtf|xls|ppt)$><br />
<br />
ExpiresDefault "access plus 10 years"<br />
<br />
</FilesMatch><br />
<br />
ExpiresByType application/x-shockwave-flash A315360000<br />
<br />
ExpiresByType application/pdf A315360000<br />
<br />
ExpiresByType application/msword A315360000<br />
<br />
ExpiresByType application/rtf A315360000<br />
<br />
ExpiresByType application/vnd.ms-excel A315360000<br />
<br />
ExpiresByType application/vnd.ms-powerpoint A315360000<br />
<br />
</IfModule><br />
<br />
FileETag none<br />
<br />
<IfModule mod_deflate.c><br />
<br />
<FilesMatch "\.(php|html)$"><br />
<br />
SetOutputFilter DEFLATE<br />
<br />
</FilesMatch><br />
<br />
</IfModule><br />
<br />
#Strip categories/ from the URL thus .com/category-name/<br />
<br />
RedirectMatch 301 ^/categories/(.*)$ http://www.domain.com/$1<br />
<br />
redirect 301 /categories/Category-Name/ http://www.domain.co.uk/category-name
``` <br />
<br />
Even if I change this:```php
RedirectMatch 301 ^/categories/(.*)$ http://www.domain.com/$1
```<br />
To redirect .com/products/Product-Name.html to .com/product-name.html, this whole setup still doesn't work.<br />
<br />
<br />
Sorry for the long rambling (incoherent) post, it's late <img src="upload://2gefrk5yIQmBF7b3nb7uvIojpeG.gif" class="bbc_emoticon" alt=":("> <br />
<br />
I would appreciate your thoughts if you could spare a moment to think this one through! Thanks