Yii2 从 url 中删除 index.php [英] Yii2 remove index.php from url

查看:16
本文介绍了Yii2 从 url 中删除 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Yii 中设置选项以从 URL 中删除 index.php 时,我收到 404 错误,并且错误日志中的此错误文件不存在:/var/live/var.在我的浏览器中,我收到此错误 在此服务器上找不到请求的 URL/var/decat/frontend/web/index.php. 但该文件正是在该位置.可以解释的是,我的文档根目录是 /var/live,而 decat 是 conf 文件中显示的别名.

When I set the option in Yii to remove index.php from the URL I get a 404 error and this error in the error logs File does not exist: /var/live/var. In my browser I get this error The requested URL /var/decat/frontend/web/index.php was not found on this server. but the file is exactly in that location. What might explain that is that my document root is /var/live and decat is an alias as shown in the conf file.

这个网址工作正常 http://13.21.16.180/decat/index.php/site/login 但是当我删除 index.php 时出现错误.我按照所有说明在 conf 文件中进行了设置.我什至尝试过 .htaccess 文件.这是我的 conf 文件中的信息.

This url works fine http://13.21.16.180/decat/index.php/site/login but when I remove index.php is when I get the error. I followed all the instructions to set it up in the conf file. I even tried through an .htaccess file. Here is the info from my conf file.

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>

推荐答案

RewriteEngine on之后添加RewriteBase/decat/并重启apache.

Add RewriteBase /decat/ after RewriteEngine on and restart apache.

这篇关于Yii2 从 url 中删除 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆