1

我正在使用 Yii2 高级模板localhost,我想将用户重定向到backend/weburl 的时间localhost/site/admin并重定向到frontend/weburllocalhost/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
4

2 回答 2

0

不使用它site

localhost/admin
于 2019-08-15T15:21:41.110 回答
0

虽然我已经mod_rewrite通过以下命令通过终端启用:

sudo a2enmod rewrite

但它没有启用,我从 ‍<code>/etc/apache2/apache2.conf 手动激活它。

于 2019-08-07T05:24:30.327 回答