Apache 2.2
DocumentRoot "/var/www/example.com/public"
<Directory "/var/www/example.com/public">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
Apache 2.4
apache 2.4 的 rewrite 需要多配置一个 RewriteBase
如果项目部署在域名根目录, 则在 RewriteEngine on
后面添加一行
DocumentRoot "/var/www/example.com/public"
<Directory "/var/www/example.com/public">
RewriteEngine On
RewriteBase "/"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</Directory>
原文