简体   繁体   中英

Redirect from a domain without hosting

I have 2 domains, the first is old, not hosting assigned and redirects to the new domain, in which a prestashop with friendly urls is installed.

www.olddomain1.com >> www.newdomain2.com

The problem is when there are parameters in the old domain and want to redirect the new domain with the friendly url.

www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/cat=74

As I can do redirections so that:

www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/pillows

That way I can set this up? Is there any way that is not hosting the old assign a domain?

First you need to configure DNS CNAME record for www.olddomain1.com that is pointing to www.newdomain2.com . That way all requests for www.olddomain1.com will go to your new web server.

Next, you need to configure your new webserver to respond to requests that have Host: www.olddomain1.com header.

If above two steps are done, all you need is mod_rewrite rule, but you need to provide exact and precise explanation what is being rewritten to. if all you need is www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/cat=74 , then this should do:

RewriteEngine On
RewriteBase "/"
RewriteCond %{HTTP_HOST} www.olddomain1.com
RewriteCond %{QUERY_STRING} cat=(.+)
RewriteRule shop/home.php http://www.newdomain2.com/cat=%1? [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM