如何重定向格式的网址
www.example.com/movies/[anything]/[anything]/[string].html
www.example.com/tv/[anything]/[anything]/[string].html
www.example.com/videogame/[anything]/[anything]/[string].html
到
www.example.com/redirect/movies/[string]
www.example.com/redirect/tv/[string]
www.example.com/redirect/videogame/[string]
答案 0 :(得分:2)
您可以将此规则放在root .htaccess
中:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/[^/]+/[^/]+/([^.]+/)\.html$ $1/$2 [L,NC,R]
答案 1 :(得分:0)
在@anubhava的帮助下,这就是我最终的目标。
RewriteEngine On
RewriteBase /
RewriteRule ^movies/([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z0-9-]+)\.html$ redirect/movies/$3 [L,NC,R]
RewriteRule ^tv/([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z0-9-]+)\.html$ redirect/tv/$3 [L,NC,R]
RewriteRule ^videogame/([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z0-9-]+)\.html$ redirect/videogame/$3 [L,NC,R]