从.htaccess文件重定向URL
如何重定向格式的url从.htaccess文件重定向URL,.htaccess,drupal-7,.htaccess,Drupal 7,如何重定向格式的url www.example.com/movies/[anything]/[anything]/[string].html www.example.com/tv/[anything]/[anything]/[string].html www.example.com/videogame/[anything]/[anything]/[string].html 到 您可以将此规则放置在root.htaccess: RewriteEngine On RewriteBase / Re
www.example.com/movies/[anything]/[anything]/[string].html
www.example.com/tv/[anything]/[anything]/[string].html
www.example.com/videogame/[anything]/[anything]/[string].html
到
您可以将此规则放置在root
.htaccess
:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/[^/]+/[^/]+/([^.]+/)\.html$ $1/$2 [L,NC,R]
在@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]
感谢@anubhava的回复,我们没有.htaccess选项进行测试。我刚刚更新了问题。再次感谢@anubhava。我仍然有问题,因为重写规则没有重定向url。请确保这是您的第一条规则。。。并使用最新更新的规则。
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]