I have this problem with my .htaccess
file.
Google has some URL's indexed I don't want (404 Error) in Webmaster Tools.
I need to rewrite URL's that include --
, /-
or an ending in -
like so:
- replace
--
with-
- remove the
-
after the/
- remove the ending
-
...but only if the URL doesn't contain product_info.php
.
I tried with this but it's not working...
RewriteCond %{REQUEST_URI} !^/product_info\.php(.*)$
RewriteRule ^(.*)--(.*)$ /$1-$2 [L,R=301]
RewriteRule ^(.*)/-(.*)$ /$1/$2 [L,R=301]
RewriteRule ^(.*)-$ /$1$2 [L,R=301]
It's on a Magento Ecommerce Shop with Varnish cache activated.
Edit #1:
Yes, they appear in the 404 error Report!
By not working I mean: The Magento Says "This document has moved here". If I click there, there is an "ESI Block error"
There can be stuff after the product_info.php?product=TestProduct--Green--XXL
In that case, I don't want to replace the --
to -
=> that's the problem I think.
Edit #2:
Here's the full .htaccess
. I removed comments expect the redirects I'm trying to get working because of lot's of space.
DirectoryIndex index.php
<IfModule mod_php5.c>
php_value memory_limit 6144M
php_value max_execution_time 18000
php_flag magic_quotes_gpc off
php_flag session.auto_start off
php_flag suhosin.session.cryptua off
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
</IfModule>
<IfModule mod_ssl.c>
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/rma/
RewriteRule ^ - [L]
#RewriteCond %{REQUEST_URI} !^/product_info(.*)
#RewriteRule ^(.*)--(.*)$ /$1-$2 [L,R=301]
#RewriteCond %{REQUEST_URI} !^/product_info(.*)
#RewriteRule ^(.*)/-(.*)$ /$1/$2 [L,R=301]
#RewriteCond %{REQUEST_URI} !^/product_info(.*)
#RewriteRule ^(.*)-$ /$1$2 [L,R=301]
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
AddDefaultCharset Off
<IfModule mod_expires.c>
ExpiresDefault "access plus 1 year"
</IfModule>
Order allow,deny
Allow from all
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
<Files cron.php>
Order allow,deny
Deny from all
</Files>