[英]Issues with htaccess redirecting http to https
我的服務器中的htaccess文件有問題。 當嘗試將http重定向到https時,它變得瘋狂了。
如果我這樣做:
ErrorDocument 400 /errores/error400.php
ErrorDocument 404 /errores/error404.php
ErrorDocument 403 /errores/error403.php
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)$ /index.php?lang=$1
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?lang=$1&go=$2
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?lang=$1&go=$2&action=$3
正常,只是沒有將http重定向到https
但是當我把這個:
ErrorDocument 400 /errores/error400.php
ErrorDocument 404 /errores/error404.php
ErrorDocument 403 /errores/error403.php
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^([A-Za-z0-9_-]+)$ /index.php?lang=$1
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?lang=$1&go=$2
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?lang=$1&go=$2&action=$3
服務器重定向到HTTPS,而是把URL喜歡https://server.com/en/home
它https://server.com/folder1/folder2/web/portal/en/home
而且我不知道該怎么辦。
提前致謝
我建議您將重寫規則與標志匹配,特別是對於HTTPS重定向。
這是適用於我的生產服務器的內容:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
當您輸入[L]時,它告訴apache停止處理以下規則,這些規則也與(.*)
匹配。 您可以在此處找到有關該標志的更多信息: RewriteRule標志
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.