簡體   English   中英

.htaccess 301重定向舊域子文件夾,而無需根域訪問新域根

[英].htaccess 301 redirect old domain sub-folder without root domain access to new domain root

我試圖將我的網站從我只是用戶的域和服務器移到我控制的域。

我想將http://www.olddomain.com/~username/上的每個請求重定向到http://www.newdomain.com/-並且我只能訪問服務器上的〜username。

我嘗試的所有內容都以http://www.newdomain.com/~username/結尾

1)

Redirect 301 / http://www.newdomain.com/

2)

Redirect 301 /~username/ http://www.newdomain.com/

3)

RewriteEngine on
RewriteBase /
RewriteRule ^~username/(.*)$ http://www.newdomain.com/$1 [R=301,NC,L]

4)

RewriteEngine on
RewriteBase /~username/
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NC,L]

我可能希望將所有內容都重定向到http://www.newdomain.com/index.html ,但是出於完整性考慮,還請顯示如何重定向到新服務器上的匹配URL。

Apache mod_rewrite文檔:

https://httpd.apache.org/docs/current/mod/mod_rewrite.html

根據@Capsule的評論,我只需要清除瀏覽器中的緩存。 刷新頁面/重新訪問舊域是不夠的。

Firefox->歷史記錄->清除最近的歷史記錄...->上一小時

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM