如何重定向到https://example.com/ https://www.example.com/

编程入门 行业动态 更新时间:2024-10-24 02:26:15
本文介绍了如何重定向到example/ www.example/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在这个code我国的.htaccess 文件,如下图所示。

I have this code in my .htaccess file as shown below.

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}

这被添加到HTTP重定向到https所以整个网站现在是HTTPS版本。

This was added to redirect http to https so the entire site is now in https version.

现在我想从非www到www重定向。当我键入​​example我应该被重定向到 www.example/

Now I want to redirect from non-www to www. When I type example I should be redirected to www.example/

我如何做到这一点与的.htaccess 文件?

How do I do that with an .htaccess file?

推荐答案

非SSL重定向:结果

RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\ RewriteRule ^(.*)$ www.domain$1 [R=permanent,L]

SSL重定向:结果

SSL redirection:

RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\ RewriteRule ^(.*)$ www.domain$1 [R=permanent,L]

更多推荐

如何重定向到https://example.com/ https://www.example.com/

本文发布于:2023-11-01 11:37:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549240.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   https   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!