如何将example.com/some/directory/path重写为archive.example.com/some/directory/path

时间:2019-04-23 22:07:28

标签: .htaccess redirect url-rewriting

正在重新设计网站。同时,我在example.com上建立了一个登录页面,并将原始站点移到了archive.example.com

我希望所有带有路径的URL重定向到存档站点并保留该路径。

example.com/any/directory/path-> archive.example.com/any/directory/path

很明显,我不希望example.com重定向。

更新:我还需要example.com/admin才能重定向

1 个答案:

答案 0 :(得分:0)

必须有一种更好的方法来完成此操作,但是以下内容在我的.htaccess文件中对我有用。

# These redirect subpages to the archive site - ORDER MATTERS
RedirectMatch 302 (/asset-type(.*)) https://archive.example.com/$1
RedirectMatch 302 (/about-us(.*)) https://archive.example.com/$1
RedirectMatch 302 (/news(.*)) https://archive.example.com/$1
RedirectMatch 302 (/portfolio(.*)) https://archive.example.com/$1
RedirectMatch 302 (/services(.*)) https://archive.example.com/$1
RedirectMatch 302 (/development(.*)) https://archive.example.com/$1
RedirectMatch 302 (/investment(.*)) https://archive.example.com/$1