使用.htaccess尝试从网址中删除/网页时找不到404页面

时间:2017-03-22 04:44:43

标签: .htaccess yii2 yii2-basic-app

我试图使用.htaccess文件从Yii2基本temeplate中的网址中删除此/ web。我已经找到了解决方案,但问题已经发生了! 所以我之前找到的解决方案是:

1)放入root / web文件夹.htaccess:

RewriteEngine On RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

2)放入根文件夹.htaccess:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

3)在请求部分' baseUrl' =>中添加 config / web.php ''

在完成步骤2和3之后出现问题。浏览器告诉:

未找到 在此服务器上找不到请求的URL /web/index.php。 Apache / 2.4.23(Win64)PHP / 5.6.25服务器在localhost端口80

当我在我的本地服务器上进行WAMP时,所有这些都会发生。我试图把这个项目放在免费托管上,而且似乎在那里工作。那么如何在本地服务器上修复此问题?为什么它会给我404错误?

1 个答案:

答案 0 :(得分:0)

尝试根.htaccess替换

RewriteRule (.*) /web/$1

RewriteRule ^(.*)$ /web/$1 [L,PT]
相关问题