url:
www.sub.example.com/old/id/345 (345 is post id)
所需的网址:
www.sub.example.com/new/345
试过这个,但不起作用:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/old/id/(.*)$
RewriteRule ^(.*) http://sub.example.com/new/%1 [R=302,NC]
谢谢!
您可以在根 .htaccess 中使用此规则:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www'.)?sub'.example'.com$ [NC]
RewriteRule ^old/id/(.+)$ /new/%1 [R=302,NC]
尝试:
RewriteRule ^/old/id/(.*)$ http://sub.example.com/new/$1 [R=302,NC]
确保您已允许mod_rewrite
。