繁体   English   中英

如何使用 www 将非 www 和 http 重定向到 https?

[英]How to redirect non www and http to https with www?

如何通过htaccess将非www和http重定向到带有www的https? 我想将旧文件夹重定向到主页,如http://.test.com/test1/about.phphttps://www.test.com

将这些行放在网络服务器根目录下的 .htaccess 文件中:

Redirect 301 /test1/about.php to https://www.test.com

还要确保您没有在 apache 配置中禁用 .htaccess。

在您的服务器配置上试试这个配置:

 RewriteEngine On
 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
 RewriteCond %{SERVER_PORT} !^443$
 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM