我遇到与用户in this thread.相同的问题我基本上想要使用htaccess
将所有http请求重定向到没有www的https。
我已经实施了一个solution to this problem,它做得非常好。
但是,它不会重定向到相应的URI。如果我在端口80 example.com/news
上访问我的网站,我将被重定向到https://example.com/index.php
,这基本上就是根页面。
我真的需要你的帮助,我完全不知道htaccess ..
编辑这就是我的mod_rewrite的样子..
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
答案 0 :(得分:0)
问题可能是您首先重写为index.php
然后进行外部重定向。尝试更改规则的顺序。请注意,L
标志仅终止当前遍历规则集。之后重新启动。因此首先执行外部指示切换到https
协议,然后执行内部重写(如果已更正)。