Josep
Josep

Reputation: 27

How to transform RedirectMatch to RewriteCond in htaccess

Could you help me please to transform this functions to "rewritecond" format? I need to change from this format:

RedirectMatch 301 ^/folder_A/([^/]+/.+?)\.html$ /$1/

RedirectMatch 301 ^/folder_A/([^/.]+\.html)$ /$1

To something like this:

RewriteCond %{REQUEST_URI} XXXXX RewriteRule XXXXX [L,R=301]

RewriteCond %{REQUEST_URI} XXXXX RewriteRule XXXXX [L,R=301]

Here my actual .htaccess file:

DirectoryIndex index.html index.php

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^tienda_2011/([^/]+/.+?)\.html$ /store_copia/es/$1/ [L,R=301]
RewriteRule ^tienda_2011/([^/.]+\.html)$ /store_copia/es/$1 [L,R=301]

#RedirectMatch 301 ^/tienda_2011/([^/]+/.+?)\.html$ /store_copia/es/$1/
#RedirectMatch 301 ^/tienda_2011/([^/.]+\.html)$ /store_copia/es/$1

# So "RewriteBase" should be:
# RewriteBase /store/cart 
RewriteBase /tienda_2011
RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} .*\/catalog\/.*
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteRule . index.php?sef_rewrite=1 [L,QSA]

</IfModule>

Upvotes: 1

Views: 1557

Answers (1)

anubhava
anubhava

Reputation: 785128

You don't need RewriteCond. Just pattern in RewriteRule will be be able to handle this:

RewriteRule ^([^/]+/.+?)\.html$ /$1/ [L,R=301]

RewriteRule ^([^/.]+?)-es(\.html)$ /$1$2 [L,R=301]

RewriteRule ^([^/.]+\.html)$ /$1 [L,R=301]

Upvotes: 1

Related Questions