尝试使用.htaccess从url中删除/web时未找到yii2 404页面

尝试使用.htaccess从url中删除/web时未找到yii2 404页面,.htaccess,yii2,yii2-basic-app,.htaccess,Yii2,Yii2 Basic App,我正在尝试用.htaccess文件从Yii2基本模板的url中删除此/web。我已经找到了解决办法,但问题已经出现了! 因此,我在前面找到的解决方案是: 1) 放入根目录/web文件夹。htaccess: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php Options +FollowSy

我正在尝试用.htaccess文件从Yii2基本模板的url中删除此/web。我已经找到了解决办法,但问题已经出现了! 因此,我在前面找到的解决方案是:

1) 放入根目录/web文件夹。htaccess:

RewriteEngine On RewriteBase /

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

RewriteRule . index.php
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
2) 放入根文件夹。htaccess:

RewriteEngine On RewriteBase /

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

RewriteRule . index.php
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) 在请求中添加config/web.php

执行步骤2和步骤3后出现问题。浏览器显示:

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


所有这些都发生在我在本地服务器(WAMP)上执行时。我试着把这个项目放在免费的主机上,所有的东西似乎都在那里工作。那么,如何在本地服务器上解决此问题?为什么会出现404错误?

在root.htaccess中尝试替换

RewriteRule (.*) /web/$1