apache - 烦人的 Silex 子目录 .htaccess 问题

标签 apache mod-rewrite silex

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

相关文章:

javascript - 如何阻止用户使用 javascript 链接

apache - htaccess mod_rewrite 主机名

.htaccess - 用一行 htaccess 让 URL 变得漂亮

php - 当 url 指向现有文件夹(无尾部斜杠)时如何重定向到 404。 HAproxy 或 mod-rewrite 相关

apache - 禁用特定重写位置的 http 身份验证

php - 使用 Silex 的 Twig addFilter?

linux - 阻止 apache 将基本身份验证 header 转发到反向代理 tomcat 站点

PhpStorm 自动完成对 Pimple 管理的未知对象属性的支持?

php - Silex app->redirect 不匹配路由

java - 如何手动运行 netbeans webapp