2013-12-21 45 views
1

我想重定向的主頁是mydomain.com到mydomain.com/index.php?cat=homemod_rewrite的:重寫規則相互

這裏confilicting是我htacess文件規則:

RewriteRule index.php index.php?cat=home [L] 
RewriteRule (.*)-live-streaming-online.html index.php?cat=$1 [L] 

當兩個活躍在我的網站的每個頁面的任何貓被重定向到index.php?貓=家庭

什麼是錯的這個htacess?

+0

@JonLin你能幫忙嗎? – user3080937

+0

在第一個重寫規則的末尾添加$也是'。'有一個特殊的含義,用'\'。而不是 – Mahakala

+0

@Mahakala澄清你的答案請,我試過/但沒有工作 – user3080937

回答

0

有你DOCUMENT_ROOT/.htaccess文件的規則是這樣的:

RewriteEngine On 

RewriteRule ^(.+?)-live-streaming-online\.html$ /index.php?cat=$1 [NC,L,QSA] 

RewriteCond %{THE_REQUEST} \s/+(index\.php)?[\s/?] [NC] 
RewriteCond %{QUERY_STRING} ^$ 
RewriteRule^/index.php?cat=home [L] 

關鍵是使用%{THE_REQUEST}代表Apache接收到原始請求。其他使用來自RewriteRule的URI patten可以根據您的其他規則進行更改。

+0

它給予500內部服務器錯誤 – user3080937

+0

哦,沒問題,你現在可以嘗試更新代碼嗎? – anubhava

+0

它的工作,但不是我想要的網址仍然顯示爲mydomain.com而它加載mydomain.com/index.php?cat=home – user3080937