【问题标题】:Without Url Change redirect from one domain to another domain没有 URL 更改从一个域重定向到另一个域
【发布时间】:2015-12-16 23:03:46
【问题描述】:

我想将一个域重定向到另一个域,但不更改 URL。

例如:

ADomain.com redirect to BDomain.com/xxx/xxx/xxx/?xxx=xxxx

我尝试了一些 htaccess

RewriteCond %{HTTP_HOST} ^(www\.)?ADomain\.com$ [NC]
RewriteRule ^(.*)$ http://BDomain.com/xxx/xxx/xxx/?xxx=xxx [R,L,NC]

这段代码被完美地重定向了。但它会将当前浏览器 url (ADomain.com) 更改为原始链接 (BDomain.com/xxx/xxx/xxx/?xxx=xxxx)。但我不需要它。我只想保留网址 ADomain.com。请指导我任何人。谢谢提前

【问题讨论】:

标签: php .htaccess redirect


【解决方案1】:

将此 PHP 代码添加到 index.php 中

<?php

function dwn_prt($url,$user_agent='Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)') 
{ 
$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); 
curl_setopt ($ch, CURLOPT_HEADER, 0); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_REFERER, 'http://ADomain.com');
$result = curl_exec ($ch); 
curl_close ($ch); 
return $result; 
}
  echo dwn_prt('http://BDomain.com/xxx/xxx/xxx/?xxx=xxxx');
?>

【讨论】:

  • 这仅适用于主页。如果我单击主页上的任何链接,它将不起作用。我该如何解决这个问题
猜你喜欢
  • 2014-01-18
  • 2020-10-01
  • 2018-04-07
  • 2015-10-24
  • 2013-05-18
  • 2015-08-20
  • 2017-05-18
  • 2011-04-12
  • 2018-10-27
相关资源
最近更新 更多