簡體   English   中英

Mod_Rewrite:相互沖突的重寫規則

[英]Mod_Rewrite: Rewrite Rules confilicting with each other

我想將mydomain.com主頁重定向到mydomain.com/index.php?cat=home

這是我的htacess文件規則:

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

當兩者都處於活動狀態時,無論我的貓如何重定向到index.php?cat = home

這個動作有什么問題?

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模式的對象可以根據您的其他規則進行更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM