簡體   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