Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess URL重写以前重写的URL-htaccess_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess URL重写以前重写的URL-htaccess

.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/文件夹中,包含以下内容:

好吧,那么。。。我的网站上有以下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/
文件夹中,包含以下内容:

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负载平衡器,所使用的协议在该报头中传输。