簡體   English   中英

.htaccess HTTPS重定向工作,但HTTPS轉到/index.php

[英].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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM