重定向一个子域网址根域名网址 [英] Redirect single subdomain url to root domain url

查看:229
本文介绍了重定向一个子域网址根域名网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待301重定向一个子一个URL到根域上的URL。例如:

I am looking to 301 redirect a single url on a subdomain to a url on the root domain. Eg:

sub.domain.com/page重定向到 domain.com/work/name

'sub.domain.com/page' to redirect to 'domain.com/work/name'

我不希望影响到的子域的任何其他网页,子域应该正常运作,除了一个特定的URL。

I do not want to affect any other pages on the subdomain, the subdomain should operate as normal, aside from that one specific url.

这将如何实现的。htaccess的?

How would this be achieved the .htaccess?

在此先感谢。 达雷尔

推荐答案

使用mod_rewrite,你可以在你的子域的文档根目录htaccess文件把这些规则:

Using mod_rewrite, you can put these rules in the htaccess file in your subdomain's document root:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^folder/page$ http://domain.com/work/name [L,R=301]

这篇关于重定向一个子域网址根域名网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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