从HTTPS重定向HTTP会导致URL重复

时间:2015-07-20 18:30:29

标签: apache .htaccess mod-rewrite redirect https

我有一个简单的重定向,可以将用户从HTTP转发到HTTPS,但是当它在根URL(例如www.example.nl)上转发时,它会转发到以下内容:

https://www.example.nl/example.nl//

发生了什么以及如何阻止它?

我的COMPLETE .htaccess文件看起来像这样:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE,NC,R,L]

RewriteRule ^sleek-yourself/share/([^/]*)$ /sleekYourself.php?share=$1 [L]

php_value upload_max_filesize 100M
php_value post_max_size  100M

我尝试在RewriteRule的末尾更改可选参数,但它没有帮助。

1 个答案:

答案 0 :(得分:0)

根据Zimmi的评论,我通过将事情改为:

来解决这个问题
RewriteRule (.*) https://%{HTTP_HOST}/$1 [NE,NC,R,L] 

使用$1代替%{REQUEST_URI}