Yii2非https和www url已重定向到前端/web

Yii2非https和www url已重定向到前端/web,yii2,virtualhost,Yii2,Virtualhost,我在Yii2中遇到了关于URL的奇怪问题 当我访问myweb.com,www.myweb.com,http://myweb.com, https://myweb.com我被重定向到https://www.myweb.com/frontend/web并显示404错误 但是当我访问https://www.myweb.com它工作正常,未显示错误 请帮我解决这个问题,我想这是因为virtualhost或.htaccess配置是我的virtualhost 端口80非https/etc/apache2/s

我在Yii2中遇到了关于URL的奇怪问题

当我访问
myweb.com,www.myweb.com,http://myweb.com, https://myweb.com
我被重定向到
https://www.myweb.com/frontend/web
并显示404错误

但是当我访问
https://www.myweb.com
它工作正常,未显示错误

请帮我解决这个问题,我想这是因为virtualhost或.htaccess配置是我的virtualhost

端口80非https/etc/apache2/sites available/myweb.com.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        ServerName myweb.com
        ServerAlias www.myweb.com

        DocumentRoot /var/www/html/myweb/frontend/web
        Redirect / https://myweb.com/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Listen 443
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        ServerName myweb.com
        ServerAlias www.myweb.com
        DocumentRoot /var/www/html/myweb/frontend/web

        SSLEngine On
        SSLCertificateFile "/home/jun/certificate.crt"
        SSLCertificateKeyFile "/home/jun/private.key"
        SSLCACertificateFile "/home/jun/ca_bundle.crt"

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
这是项目文件夹中的
.htaccess

# prevent directory listings
Options -Indexes
IndexIgnore */*

# follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^administrator(/.+)?$ backend/web/$1 [L,PT]
RewriteRule ^(.+)?$ frontend/web/$1

RewriteCond %{HTTP_HOST} ^myweb\.com [NC]
RewriteRule ^(.*)$ https://www.myweb.com/$1 [L,R=301]
这是frontend/web中的
.htaccess

RewriteEngine on
# RewriteBase /frontend/web
# 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
这里是我从inspect元素得到的

General
Request URL:http://myweb.com/
Request Method:GET
Status Code:301 Moved Permanently (from disk cache)
Remote Address:123.231.250.140:80
Referrer Policy:no-referrer-when-downgrade

Response Headers
Content-Length:243
Content-Type:text/html; charset=iso-8859-1
Date:Mon, 17 Apr 2017 08:47:29 GMT
Location:https://www.myweb.com/frontend/web/
Server:Apache
那么,我的代码或配置有什么问题


提前感谢。

您能尝试清除浏览器的缓存吗?@JannesBotis是的,错误配置virtualhost和浏览器缓存,任何人都可以在某种it上使用gtmetrix进行检查,而无需缓存。