所以我有兩條規則。每條規則都完全按照它自己在.htaccess
中的內容執行,但是當兩條規則都在那裏時,它們就開始相互衝突。兩個RewriteCond和RewriteRule獨立工作
RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^(.*)\.html$ index.php?id=$1 [QSA,L]
上述規則越來越說http://domain.com/12.html
和傳球次數12
到index.php
只有工作正常,如果數量與.html
結束(注意:12.html
文件不存在!)
RewriteCond %{REQUEST_URI} !^(.*)\.html$
RewriteRule ^(.*)$ /$1\.html [L,R=301]
該作品可以檢查URL是否以.html
結尾。如果它沒有完成.html
,它會將其重定向到URI + .html
(這也可以很好地工作)。
當我在一個.htaccess
RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^(.*)\.html$ index.php?id=$1 [QSA,L]
RewriteCond %{REQUEST_URI} !^(.*)\.html$
RewriteRule ^(.*)$ /$1\.html [L,R=301]
兩個規則則有導致重定向循環迴路。
有人可以指出我哪裏出錯了嗎?
如果您只是使用第二個重寫規則,它會對'http://domain.com/index.php?id = 12'做什麼? – Neil
它returnn:http://domain.com/index.php.html?id=12 –