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