2022年5月16日 星期一

Apache2 Rewrite 設定範例

開啟 Rewrite模組
a2enmod rewrite

確認
apache2ctl -M | grep rewrite

編輯 /etc/apache2/sites-enabled/000-default.conf  加入
<Directory "/var/www/html">
 AllowOverride All
</Directory>

編輯 /var/www/html/.htaccess 加入
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]
</IfModule>

沒有留言: