重寫規則為什么要options +followsymlinks
Web服務器的Apache安裝編譯成功mod_rewrite編譯成模塊,但當我在網站根目錄下放了一個.htaccess配置文件,卻得到了一個500內部服務器出錯。
我打開我的.htaccess配置文件,發現文件頭有 Options +FollowSymlinks
上網查了一下"在 某些服務器配置中,mod_rewrite要求有followsymlinks,否則會顯示500內部服務器錯誤。
[In some (or all?) server configurations, mod_rewrite requires followsymlinks to be enabled, or it will crater with a 500-Server Error.]
在任何情況下,只要您沒有指定FollowSymLinks的選項(即Options FollowSymLinks),或者指定了SymLinksIfOwnerMatch選項,Apache將不得不調用額外的系統函數來檢查符號鏈接。每次針對文件名的請求都將觸發一次檢查。
如果你沒有使用followsymlinks規則而網站訪問正常,說明你的服務器配置已經默認調用followsymlinks的重寫規則,你無需再為你的htaccess文件定義了。但在有些服務器500 Server Error之后的錯誤日志中提示需要定義SymLinks使得rewrite重寫規則起作用。
If your mod_rewrite code works without the options +followsymlinks directive, that means that your server configuration file has enabled them already, and you won't need that directive in your .htaccess files.
The requirement for enabling followsymlinks is not well-defined. The only way I learned about it was because I got a 500-Server Error the first time I ever enabled mod_rewrite, and the error log entry said something to the effect of, "You must enable SymLinks for this to work."