0
我試圖使用mod_rewrite將現有文件重定向到不同的URL。我正在使用以下內容,但沒有任何效果。我已經嘗試過幾種不適用的變體。使用mod_rewrite將現有文件重定向到不同的URL
RewriteEngine on
AddHandler x-httpd-php .php3
# AddHandler x-httpd-php5 .php .php4
# This file exists, but this redirect doesn't work
RewriteRule ^show.php?id=review-1$ /review/1/super-baseball-2020/ [R=301,L]
這是否偶然與url params有關?
這可以解決;然而,因爲'/ review/1/super-baseball-2020 /'實際上是'shows.php?id = review-1'的一個RewriteRule,它會進入一個無限的重定向循環。有什麼建議麼? – 2012-02-06 04:51:03
您需要註釋掉/刪除您現有的規則:'RewriteRule^show.php?id = review-1 $/review/1/super-baseball-2020/[R = 301,L]' – anubhava 2012-02-06 04:52:31
我確實擺脫了那。這是什麼在我的.htaccess 'RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule ^([a-z0-9] +)/([0-9] +)/ ([| 0 | - ] +)?/?$ /shows.php?id=$1-$2 [L] RewriteCond%{QUERY_STRING}(^ |&)id = review-1(&| $)[ NC] RewriteRule^shows \ .php $/review/1/super-baseball-2020/[R = 301,L,NC]' – 2012-02-06 04:55:45