当我在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>
5条答案
按热度按时间gg58donl1#
在
RewriteEngine on
之后添加RewriteBase /decat/
,然后重新启动apache。t9aqgxwy2#
应按如下方式设置Url Manager组件:
正式文件:
wmtdaxz33#
您应该将.htaccess更改为
和urlManager规则为
我在我的应用程序中使用这个。它工作。我的网址鞋作为www.example.com/user/view?id=1
rmbxnbpk4#
yii 2从url中删除网页
1)使用以下命令编辑您的config/web.php文件:
2)将以下htaccess添加到root/web
3)将以下htaccess添加到安装应用程序的根文件夹
pprl5pva5#
我想是你的Apache配置错了......你告诉它在我阅读的时候只重写一个字符的请求?
我认为它需要:
但我可能会错,不是一个
apache
Maven