簡體   English   中英

.htaccess似乎在忽略RewriteCond

[英].htaccess seems to be ignoring RewriteCond

這是我擁有的htaccess:選項+ FollowSymlinks

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/pages
RewriteRule ^(.+)/$ /$1 [NC]
RewriteRule ^$ /pages/index.php [NC]
RewriteRule ^([a-z]+)\?([^/]+)$ /pages/$1.php?$2 [NC]
RewriteRule ^([a-z]+)/([^/]+)$ /pages/$1.php?q=$2 [NC]
RewriteRule ^([a-z]+)$ /pages/$1.php [NC]
ErrorDocument 404 /pages/404.php

應該做的很簡單:

  • 從網址中刪除斜杠
  • 將example.com/tomato直接指向example.com/pages/tomato.php
  • 直接將example.com/tomato?c=red&size=big指向example.com/pages/tomato.php?c=red&size=big
  • 直接將example.com/tomato/red轉到example.com/pages/tomato.php?q=r

但這是問題所在:/pages/tomato.php的任何URL都與.htaccess的第7行匹配,這會產生無限循環。 這就是為什么我為/ pages添加了一個異常,但它似乎被忽略了-此日志消息仍然導致500 Internal Server Error:

mod_rewrite:達到內部重定向的最大數量。 假設配置錯誤。 如有必要,使用“ RewriteOptions MaxRedirects”增加限制。

這可能與我在虛擬主機上運行該事實有關嗎? 如果是這樣,應如何解決?

RewriteCond僅適用於下一個RewriteRule,因此您必須為每個規則復制該條件。

您可以在其他規則之前使用中斷規則:

RewriteRule ^pages/ - [L]

暫無
暫無

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

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