線上書籍

Home

網管技術

Apache Mod_rewrite 開啟教學

修改 apache2 下的

# pico /etc/apache2/mods-available/rewrite.load
搜尋並將以下兩行,如果有# 的話,把前面的注解「#」拿掉

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c

 

# pico /etc/apache2/apache2.conf
加入

<IfModule mod_rewrite.c>    Options +FollowSymLinks    RewriteEngine On     RewriteBase /    RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]    RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]    RewriteRule ^index.php/(.*) $1 [QSA,R,L]  </IfModule>

 

# pico /etc/apache2/sites-available/default

找到 gallery3 的 虛擬網站設定,在 

<Directory /path/gallery3/>
       .............
                AllowOverride All   <---- 改成這樣
                #AllowOverride None     <----  原來的 
        </Directory>

 

再先執行這個指令使系統讓指令啟用

a2enmod rewrite 再重新啟動 apache2 service apache2 restart