2011-11-27 49 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]