.htaccess URL重写以前重写的URL-htaccess
好吧,那么。。。我的网站上有以下URL:.htaccess URL重写以前重写的URL-htaccess,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,好吧,那么。。。我的网站上有以下URL: http://my_domain.net/w/mRD3nKkM 在我的网站的根目录中对此进行重写: RewriteRule ^([w])/(\w+)$ res/$1/response.php?id=$2 [L] 简单的东西和工作的待遇。现在,我想将点击该URL的未加密流量重定向到https上,如下所示: https://my_domain.net/w/mRD3nKkM 因此,我将另一个.htaccess文件放在res/w/文件夹中,包含以下内容:
http://my_domain.net/w/mRD3nKkM
在我的网站的根目录中对此进行重写:
RewriteRule ^([w])/(\w+)$ res/$1/response.php?id=$2 [L]
简单的东西和工作的待遇。现在,我想将点击该URL的未加密流量重定向到https上,如下所示:
https://my_domain.net/w/mRD3nKkM
因此,我将另一个.htaccess文件放在res/w/
文件夹中,包含以下内容:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} ^/response.php$
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^(.*)$ https://my_domain.net/w/$1 [R,L]
我觉得这应该行得通,但不行
为了清楚起见,我有以下URL重写工作:
http://my_domain.net/w/mRD3nKkM
我希望它看起来像这样:
https://my_domain.net/w/mRD3nKkM
谢谢在执行内部转发之前,您应该先处理
http=>https
。以下内容适用于您:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^w/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]
RewriteRule ^(w)/(\w+)/?$ res/$1/response.php?id=$2 [L,NC]
在执行内部转发操作之前,应该先处理
http=>https
。以下内容适用于您:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^w/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]
RewriteRule ^(w)/(\w+)/?$ res/$1/response.php?id=$2 [L,NC]
完美的我不得不使用
RewriteCond%{HTTP:X-Forwarded-Proto}!https
,因为我使用的是AWS负载平衡器,使用的协议在该标头中传输。完美。我不得不使用RewriteCond%{HTTP:X-Forwarded-Proto}!https
,因为我使用的是AWS负载平衡器,所使用的协议在该报头中传输。