2011-06-14 55 views
0

我想在.htaccess文件中編寫規則。重寫規則不影響網站

我寫的規則是這樣的:

RewriteCond %{QUERY_STRING} ^id=([0-9]+)&dgid=([0-9]+)$ 
RewriteRule destination_content-id-(.*)-dgid-(.*)\.htm$ destination_content.html?id=$1&dgid=$2 [L] 

重新啓動服務器。

在它有以下規則之前。

RewriteEngine on 
     # Parse out basename, but remember the fact. 
     RewriteRule ^(.*)\.html$    $1  [C,E=WasHTML:yes] 
     # Rewrite to document.phtml if exists... 
     RewriteCond %{REQUEST_FILENAME}.phtml -f 
     RewriteRule ^(.*)$     $1.phtml [S=1] 
     # ...else reverse the previous basename cutout. 
     RewriteCond %{ENV:WasHTML}   ^yes$ 
     RewriteRule ^(.*)$     $1.html 

它工作正常。

但我的規則不起作用。

請幫我解決這個問題。

感謝, Srilu

+0

什麼是你想用你的重寫規則呢? – 2011-06-14 14:53:30

+0

似乎很奇怪,只有當URL已經具有相同格式的QueryString時,纔會要求重寫爲content.html?id = &gid = ?xxx- -yyy- ?zzz你有沒有嘗試刪除RewriteCond?它似乎不屬於這裏。但也許你可以詳細一點。 – 2011-06-16 00:36:04

回答

0

離開了的RewriteCond(它不匹配重寫規則)。

你只需要重寫規則,我想你希望它看起來是這樣的:

RewriteEngine on 
RewriteRule destination_content-id-([0-9]+)-dgid-([0-9]+)\.htm$ destination_content.html?id=$1&dgid=$2 [L] 
+0

是的,但它不工作。你能幫我解決這個問題嗎? – srilu 2011-06-21 10:39:48

+0

你的網址是什麼樣的?你想重寫什麼? – JochenJung 2011-06-21 11:04:29