我正在使用 Yii2 高级模板localhost
,我想将用户重定向到backend/web
url 的时间localhost/site/admin
并重定向到frontend/web
urllocalhost/site
使用.htaccess
文件的时间。
我启用apache rewrite
并尝试了这些解决方案
高级模板 Yii2 - 使用 htaccess
Yii2 重定向到前端/Web .htaccess 重定向到后端部分
通过 htaccess Yii2 重定向到后端
但在所有情况下,404 Error
当 url 是localhost/site/admin
未找到
在此服务器上未找到请求的 URL /site/admin。
并且当 url 是localhost/site
我网站的根目录的内容时,会显示给我。
现在我.htaccess
在项目的根目录是:
# prevent directory listings
Options -Indexes
IndexIgnore */*
# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^admin(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1
并且在backend/web
并且frontend/web
是:
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