我的 .htaccess 檔案中有這個:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^admin\.domain1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^admin\.domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^admin\.domain3\.com$
RewriteRule (.*) /path/to/directory/$1 [L]
RewriteCond %{HTTP_HOST} ^admin\.domain4\.com$
RewriteRule (.*) /different/path/$1 [L]
第一個塊有效,但第二個塊給了我以下錯誤:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.29 (Ubuntu) Server at admin.domain4.com.ar Port 80
我究竟做錯了什么??
uj5u.com熱心網友回復:
第一個塊有效,但第二個塊給了我一個內部服務器錯誤:
兩個規則/塊都有相同的“問題”。.htaccess第一條規則只有在您有另一個檔案/path/to/directory/也使用 mod_rewrite (可能路由 URL?)以防止內部重寫回圈(您的內部服務器錯誤的可能原因)時才會“起作用” 。
如果您使用的是 Apache 2.4,解決此問題的最簡單方法是簡單地使用END標志,而不是L. 例如:
RewriteRule (.*) /different/path/$1 [END]
該L標志僅停止當前輪次處理,它不會停止重寫引擎的所有處理。在第二次通過重寫引擎時,模式(.*)還匹配重寫的請求,該請求/different/path/<url>被進一步重寫/different/path/different/path/<url>等等,導致無限回圈,除非有什么可以阻止它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/478901.html
上一篇:資料包套接字沒有接收到資料
