.htaccess 重定向安全
到目前为止尚未找到我要查找的内容。
我想将所有网站访问者重定向到他们输入的 URL 的安全版本,因此我已将其放入我的 .htaccess 文件中。
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L]
到目前为止一切顺利,但现在我希望访问者输入
www.mywebsite.com/directory/param1/etcetera/
或www.mywebsite.com/directory/file.php?param1 =value1
被重定向到
https://www.mywebsite.com/directory/param1/etcetera/
或https://www.mywebsite.com/directory/file.php?param1=value1
也是如此,因为这没有发生。 有高手可以帮帮我吗? :) 谢谢
Haven't found what i'm looking for so far.
I want to redirect all my site visitors to the secure version of the URL they type in, so i've put this in my .htaccess
-file.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L]
So far so good, but now I want that visitors who type in
www.mywebsite.com/directory/param1/etcetera/
orwww.mywebsite.com/directory/file.php?param1=value1
are being redirected to
https://www.mywebsite.com/directory/param1/etcetera/
orhttps://www.mywebsite.com/directory/file.php?param1=value1
as well, cause that isn't happening.
Can some guru help me out? :) thnx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一个案例
www.mywebsite.com/directory/param1/etcetera/
应通过您的 RewriteRule 重定向到其 https 变体。我不明白为什么那不起作用。为了涵盖第二种情况,为了让 Apache 包含查询字符串,您需要添加 QSA 标志,所以:
Your first case,
www.mywebsite.com/directory/param1/etcetera/
, should be redirected to its https variant by your RewriteRule. I can't see why that wouldn't work.To cover the second case, in order to have Apache include the query string, you need to add the QSA flag, so: