我正在使用 Silex 处理几个项目,但在这些项目中我都无法使 .htaccess 文件正常工作。当前目录结构为http://localhost/IIV/
Silex 中的前端文件位于 http://localhost/IIV/web/index.php
这是我目前拥有的:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /IIV/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteCond %{DOCUMENT_ROOT}/web/$1 -f
RewriteRule ^(.+?)/?$ /web/$1 [L]
RewriteCond %{DOCUMENT_ROOT}/web/$1 !-f
RewriteRule ^(.+?)/?$ /web/index.php [L]
RewriteRule ^(.+?)/?$ /web/index_dev.php [L]
最佳答案
您的 RewriteBase 错误,请尝试以下操作:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /IIV/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
此外,请确保 Apache 配置为加载 .htaccess 规则,如上面提到的@Maerlyn。
关于apache - 烦人的 Silex 子目录 .htaccess 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19554125/