Apache重定向到SSL而非www

发布于 2025-01-31 20:25:39 字数 830 浏览 2 评论 0原文

我的WordPress网站上有两个域:xpemun.netexample.com,并希望将所有用户重定向到https://example.com(使用SSL和www)。

链接示例:

http://example.com 
http://www.example.com
http://example.net
http://www.example.net
https://example.com
https://www.example.com
https://example.net
https://www.example.net

我现在使用的表达式:

  RewriteEngine On
  RewriteCond %{ENV:HTTPS} !on
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我尝试使用其他一些标准表达式,它们以某种方式起作用,但是这些解决方案和所有其他解决方案都有相同的问题。他们不会将链接重定向到https://example.com/category/https://example.com/category/sub-category/sub-category/

另一种链接为www.example.net/category/some.html被重定向到example> example.com/category/some.html。不了解问题在哪里。

I have two domains on my wordpress site: example.net and example.com and want to redirect all users to https://example.com (with ssl and with out www).

Link examples:

http://example.com 
http://www.example.com
http://example.net
http://www.example.net
https://example.com
https://www.example.com
https://example.net
https://www.example.net

Expression I use now:

  RewriteEngine On
  RewriteCond %{ENV:HTTPS} !on
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

I tried to use some other standard expressions and they work somehow but this and all other solutions have the same problem. They don't redirect links to https://example.com/category/ or https://example.com/category/sub-category/
Another links as www.example.net/category/some.html are redirected to example.com/category/some.html as they should. Can't understand where is the problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文