【问题标题】:How to rewrite `example.com/some/directory/path` to `archive.example.com/some/directory/path`如何将 `example.com/some/directory/path` 重写为 `archive.example.com/some/directory/path`
【发布时间】:2019-04-23 22:07:27
【问题描述】:

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

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

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

显然我不希望example.com 重定向。

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

【问题讨论】:

  • 我的想法是将其应用到我的.htaccess 文件中

标签: .htaccess redirect url-rewriting


【解决方案1】:

必须有更好的方法来完成此任务,但以下内容在我的 .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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-16
    • 1970-01-01
    • 1970-01-01
    • 2022-07-16
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    • 2019-06-17
    相关资源
    最近更新 更多