gpt4 book ai didi

linux - Apache HTTPS URL 重写

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:30 26 4
gpt4 key购买 nike

我刚开始玩 Linux 和 Apache,但一直卡在这上面。

我有这个重写规则工作正常:

RewriteEngine on
RedirectMatch ^/$ /myserver/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myserver/ [R]

如何应用这些相同的规则重定向到 https

谢谢!

最佳答案

On the Apache wiki:

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context

如果我正确理解你的问题,你可以在你的具体示例中实现它。

请注意,建议在非安全 VirtualHost 内部使用重定向到安全 VirtualHost。

关于linux - Apache HTTPS URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46164752/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com