![](/img/trans.png)
[英]Mod_rewrite combine default path with www. and https redirect
[英]Redirect http://www. old path to https://www. new path (1to1 redirect)
與重定向http://www.
到新路徑和https://www.
由於我們要強制使用https://
因此它會從http://www.
創建一個鏈http://www.
https://www.
舊路徑https://www.
https://www.
舊路徑https://www.
新路
http://www.
舊路徑-> https://www.
舊路徑-> https://www.
新路徑301-> 301-> 200
誰能拯救我的一天? 我們如何在.htaccess(apache)中解決此問題?
如果您有一個新域名:
<VirtualHost *:80>
ServerName www.example-old.com
Redirect 301 / https://www.example-new.com
</VirtualHost>
<VirtualHost *:443>
ServerName www.example-new.com
DocumentRoot /your_document_root
SSLEngine on
...
</VirtualHost>
如果要從一個文件夾重定向到另一個文件夾:
<VirtualHost *:80>
ServerName www.example.com
Redirect permanent / https://www.example.com
</VirtualHost>
<VirtualHost *:443>
ServerName www.example.com
Redirect 301 /old-path https://www.example.com/new-path
DocumentRoot /your_document_root
SSLEngine on
...
</VirtualHost>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} wp-includes
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} old-page
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
</IfModule>
此設置有效,但是如何添加更多URI來按比例進行而不是添加20-50?
索引/首頁的URI外觀如何? 由於它是根/。 什么會代替wp-includes或old-page作為文件夾?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.