簡體   English   中英

如何將舊域的鏈接重定向到新域?

[英]How to redirect link of old domain to new domain?

我將客戶的 CMS 從一個域轉移到另一個域。 我還更改了安裝 CMS 的目錄。 舊域中的 CMS 安裝在客戶端的子目錄中,新域中的 CMS 位於 wwwroot 中。 我不想讓客戶的遷移變得困難,我想到了使用.htaccess文件插入舊域的根目錄以重定向到新域。 特別是,如果(例如)客戶在指向舊域時再次單擊 CMS 通過 email 發送給他的鏈接,他將被重定向到與新域相同的頁面。 例如,如果在客戶的 email 中有一個鏈接,例如

https://olddomain.example/clients/viewinvoice.php?id=447

將被重定向到

https://newdomain.example/viewinvoice.php?id=447

這怎么可能呢? 我試過:

RewriteEngine On 

RewriteBase /
    
RewriteRule ^clients(.*)$ https://www.newdomain.example/$1 [L,R=301]
RewriteEngine on

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ clients/$1 [L]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

Options -Indexes

按照@example-person 的指示解決

RewriteEngine On 

RewriteBase /
    
RewriteRule ^clients(.*)$ https://www.newdomain.example/$1 [L,QSA,R=301]

暫無
暫無

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

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