Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redirect 将子域重定向到另一个域_Redirect_Subdomain - Fatal编程技术网

Redirect 将子域重定向到另一个域

Redirect 将子域重定向到另一个域,redirect,subdomain,Redirect,Subdomain,当前我正在使用windows共享主机。我需要将我的子域重定向到一个新域(包括整个路径) 例如,当用户访问时,它会将用户重定向到 这是我的服务提供商建议的方法 <script language="c#" runat="server"> private void Page_Load(object sender, System.EventArgs e) { Response.Status = "301 Moved Permanently"; Response.AddHeader("Loca

当前我正在使用windows共享主机。我需要将我的子域重定向到一个新域(包括整个路径)

例如,当用户访问时,它会将用户重定向到

这是我的服务提供商建议的方法

<script language="c#" runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>

私有无效页面加载(对象发送方,System.EventArgs e)
{
Response.Status=“301永久移动”;
Response.AddHeader(“位置”http://www.new-url.com");
}
但这种方式似乎无法重定向整个url。有什么建议吗? 谢谢

*更新

尝试如下使用web.config重定向,但仍然得到500个内部错误,知道吗

    <?xml version="1.0"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rule name="CName to URL" stopProcessing="true">
        <match url=".*" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.olddomain\.com$" />
        </conditions>
        <action type="Redirect" url="http://newdomain.com/{R:0}" />
      </rule>
    </rewrite>
  </system.webServer>
    <system.web>      
        <compilation debug="false" targetFramework="4.0" />
    </system.web>
</configuration>

为什么不使用重定向方法

private void Page_Load(object sender, System.EventArgs e)
{
   response.redirect("http://newdomain.com/page1/topic1");
}

嗨,我无法硬编码url路径。例如,当用户通过搜索引擎搜索链接时,我需要将特定url连同整个路径重定向到新域。