Apache - huyx/1 GitHub Wiki
允许 .htaccess
<Directory "/var/www/web">
AllowOverride FileInfo
Require all granted
</Directory>
允许 rewrite 模块,并重启 apache2
sudo a2enmod rewrite
sudo service apache2 restart
.htaccess 配置示例
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET|POST
RewriteRule ^(\w+)s$ $1.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET|PUT|PATCH|DELETE
RewriteRule ^(\w+)s/(\w+)$ $1.php?id=$2 [QSA,L]