【发布时间】:2019-07-26 04:16:03
【问题描述】:
当我在 Yii 中设置选项以从 URL 中删除 index.php 时,我收到 404 错误,并且错误日志中的此错误 File does not exist: /var/live/var。在我的浏览器中,我收到此错误The requested URL /var/decat/frontend/web/index.php was not found on this server.,但该文件恰好位于该位置。可以解释的是,我的文档根目录是 /var/live,而 decat 是 conf 文件中显示的别名。
这个 url 工作正常 http://13.21.16.180/decat/index.php/site/login 但是当我删除 index.php 时,我得到了错误。我按照所有说明在 conf 文件中进行了设置。我什至尝试过一个 .htaccess 文件。这是我的 conf 文件中的信息。
Alias /decat /var/decat/frontend/web
<Directory "/var/decat/frontend/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
【问题讨论】:
-
配置看起来不错。你重启apache服务了吗?
-
我重新启动它,现在我收到了我在问题中发布的新错误
-
如果您说您的 DocumentRoot 是
/var/live,那么我不明白为什么您的别名是/var/decat而不是var/live。试试Alias /decat /var/live/frontend/web和<Directory "/var/live/frontend/web">... -
因为我在文档根目录中没有文件夹来增强安全性,所以我使用别名来访问唯一应该可以访问的文件夹。该文件夹位于 var/decat 中,它与 index.php 一起工作正常,因此别名正常工作
-
尝试在
RewriteEngine on之后添加RewriteBase /decat/(并重启apache)