要為 Apache 加載 mod_rewrite 模組,如果 Apache 並未安裝,可以在編譯時加上 –enable-rewrite 便可以,但如果 Apache 已經安裝好,而又不想重新編譯 Apache 的話,可以用以下方法:
- 在apache的 source code 中尋找 mod_rewrite.c 檔案
find ./ -name mod_rewrite.c
- 進入 mod_rewrite.c 的目錄並用 apxs 編譯 mod_rewrite.c
cd PATH/to/mod_rewrite.c
/usr/local/apache/bin/apxs -c mod_rewrite.c
/usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la
- 編譯好 mod_rewrite.c 後,便開啟 httpd.conf 加入以下內容:
LoadModule rewrite_module modules/mod_rewrite.so