【发布时间】:2016-09-26 19:25:14
【问题描述】:
我一直在到处搜索,但似乎无法正常工作。
这段代码运行完美:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^/?artists/[\w-]+/([\w-]+)/([\w-]+)/?$ /dir1/artist.php?artist_id=$1&page_id=$1 [L,QSA,NC]
RewriteRule ^/?tour/[\w-]+/([\w-]+)/?$ /dir2/index.php?artist_id=$1 [L,QSA,NC]
RewriteRule ^/?video/[\w-]+/([\w-]+)/?$ /dir3/index.php?artist_id=$1 [L,QSA,NC]
RewriteRule ^/?news/[\w-]+/([\w-]+)/?$ /dir4/article.php?artist_id=$1 [L,QSA,NC]
但是,在此之后,我在下面尝试了这个,并且服务器根本没有响应。它只是加载旧页面(仍在服务器上)
我的自定义重定向尝试,尝试过但不起作用
RedirectMatch 301 ^/old_dir//old_file.html /artists/subdir/21/biography/
RewriteRule /old_dir//old_file.html /artists/subdir/21/biography/ [L,R=301]
有人知道如何在第一个 RewriteRules 之后设置自定义重定向吗?
ps。甚至@anubhava 的回答都不起作用 (htaccess Redirects Not Working Right)
【问题讨论】:
标签: php apache .htaccess redirect mod-rewrite