我301怎么可以重定向特定的子域网址使用的.htaccess? [英] How can I 301 redirect specific subdomain URLs using .htaccess?

查看:161
本文介绍了我301怎么可以重定向特定的子域网址使用的.htaccess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重定向特定的URL上的子域的完全不同的的一个不同的子域网址。例如:

  http://foo.example.com/this-is-my-page
 

需要为 301 来:

  http://bar.example.com/this-is-really-my-page
 

我试着建立一个简单的重定向301 的.htaccess ,但它似乎并没有工作。例如:

 重定向301 http://foo.example.com/this-is-my-page http://bar.example.com/this-is-really-my-page
 

解决方案

下面就是我最后做:

 #第一次重新编写所有foo.example.com请求bar.example.com
的RewriteCond%{HTTP_HOST} ^富\ .EXAMPLE \ .COM [NC]
重写规则(。*)http://bar.example.com/$1 [L,R = 301]

#现在重新写每个网址
重写规则^这 - 是 - 我的空间/本 - 是 - 真的 - 我的页[NC,L,R = 301]
 

I need to redirect particular URLs on a subdomain to completely different URLs on a different subdomain. For example:

http://foo.example.com/this-is-my-page

Needs to 301 to:

http://bar.example.com/this-is-really-my-page

I’ve tried setting up a simple Redirect 301 in .htaccess but it doesn't seem to work. For example:

Redirect 301 http://foo.example.com/this-is-my-page http://bar.example.com/this-is-really-my-page

解决方案

Here's what I ended up doing:

# first re-write all foo.example.com requests to bar.example.com
RewriteCond %{HTTP_HOST} ^foo\.example\.com [NC]
RewriteRule (.*) http://bar.example.com/$1 [L,R=301]

# now re-write each individual URL
RewriteRule ^this-is-mypage /this-is-really-my-page [NC,L,R=301]

这篇关于我301怎么可以重定向特定的子域网址使用的.htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆