2013-04-25 50 views
1

幾天前,我問了一個無法回答的問題,我幾乎有它,但不是很確定,我相信這是我錯過的東西,你們可以幫我...htaccess重定向不完整的任務

下面是代碼:

RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^monitorbc\.info$ [OR] 
    RewriteCond %{HTTP_HOST} ^www\.monitorbc\.info$ 
    RewriteRule ^notas\.php?(.*) "https://monitorbc.info/monitor3/notas.php?" [R=301,L] 

    # one of the links from the old site = https://monitorbc.info/notas.php?id=699&sec=economia 
    # It should end up like this = https://monitorbc.info/monitor3/notas.php?id=699&sec=economia 

的問題是,它並重定向但由於某種原因重定向在停止?簽署,所以它沒有完成任務。

希望我這次有道理。

回答

1

在重寫規則中,您無法與查詢字符串進行匹配,因此只能在重寫條件內與%{QUERY_STRING}變量匹配。您在表達式中的?會被評估爲「php」中的最後一個「p」是可選的。但是,因爲你似乎沒有使用查詢字符串。刪除所有?標記。默認情況下,查詢字符串附加到您的規則的目標:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^monitorbc\.info$ [OR] 
RewriteCond %{HTTP_HOST} ^www\.monitorbc\.info$ 
RewriteRule ^notas\.php$ https://monitorbc.info/monitor3/notas.php [R=301,L] 
+0

太好了。非常感謝,幾天前我很抱歉這個問題非常嚴重。你的建議完美運作。 – 2013-04-25 09:58:29