简体   繁体   English

从域重定向而不托管

[英]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. 我有2个域,第一个是旧域,未分配主机,并重定向到新域,在该域​​中安装了具有友好URL的prestashop。

www.olddomain1.com >> www.newdomain2.com 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. 问题是,当旧域中有参数并且想要使用友好的URL重定向新域时。

www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/cat=74 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 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 . 首先,您需要为指向www.newdomain2.com www.olddomain1.com配置DNS CNAME记录。 That way all requests for www.olddomain1.com will go to your new web server. 这样,对www.olddomain1.com所有请求www.olddomain1.com将转到您的新Web服务器。

Next, you need to configure your new webserver to respond to requests that have Host: www.olddomain1.com header. 接下来,您需要配置新的Web服务器,以响应具有Host: www.olddomain1.com标头的请求。

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. 如果完成了上述两个步骤,则只需要使用mod_rewrite规则,但是您需要提供准确和准确的解释,以了解要重写的内容。 if all you need is www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/cat=74 , then this should do: 如果您只需要www.olddomain1.com/shop/home.php?cat=74 >> www.newdomain2.com/cat=74 ,那么这应该可以:

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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