2

我正在使用 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]
4

1 回答 1

5

你的 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 配置为像上面提到的 @Maerlyn 那样加载 .htaccess 规则。

于 2013-10-24T06:25:22.313 回答