2011-11-27 51 views
0

如何在.htaccess中执行301重定向,其中条件是第一个段中的任何2个字符,后面是第二个段中的任何数字。例如301在.htaccess中重定向,其中URL包含第二段中的数字

google.com/en/51/something/else 
google.com/fr/29/some-text 
google.com/es/111/ 

google.com/en/product/51/something/else 
google.com/fr/product/29/some-text 
google.com/es/product/111/ 

回答

0

尝试添加以下到.htaccess文件在你的域的根

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_URI} !^/[^/]{2}/product/ [NC]  
RewriteCond %{REQUEST_URI} ^/([^/]{2})/([0-9]+.*)$ [NC] 
RewriteRule . /%1/product/%2 [L,R=301]