Apache: redirecting users, but keep same path?

后端 未结 2 1387
孤街浪徒
孤街浪徒 2021-02-20 04:09

I want to be able to redirect users to a different TLD but keep the same path:

For example if the user goes to:

example.com/cars/10

Usi

2条回答
  •  旧时难觅i
    2021-02-20 04:26

    use a 302 redirect in your config:

    
      ServerName example.com
      Redirect /cars http://my_new_site.com/cars/
    
    

    If you need more flexibility, you can use mod_rewrite, and then use those rewrites:

    RewriteEngine on
    RewriteRule ^/(.*)$ http://my_new_site.com/$1 [NC]
    

    There's a nice documentation at apache.org.

提交回复
热议问题