[英]301 redirects(.htaccess) - http to https + www to non-www + 'index.php' to '/'
[英].htaccess HTTPS redirects working but HTTPS going to /index.php
对我的站点的HTTP
请求总是重定向到index.php
,因为HTTPS
请求根本不请求index.php
并按预期工作。
例如:
https://example.com/contact
不会重定向并按预期工作。
http://example.com/contact
重定向到https://example.com/index.php
,但未加载正确的请求页面。
我目前的.htaccess
看起来像这样:
# Always set these headers.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
RewriteEngine On
# RewriteCond %{SERVER_PORT} 80
# RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
它是由这部分引起的:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
http://example.com/contact变为http://example.com/index.php,因为上面的重写规则,然后您的重写规则迫使https在https://example.com/index中重写它。 PHP
我不知道你打算用我引用的部分做什么,但试着评论它并再次测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.