重定向1 TLD的另一个所有页面 [英] Redirect all pages of one TLD to another

查看:94
本文介绍了重定向1 TLD的另一个所有页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

\我该死的近拉我的头发试图弄清楚这一点今晚。我希望有人能帮助我。

\I'm darn nearly pulling my hair out trying to figure this out tonight. I'm hoping someone can help me out.

我有3个顶级域名的网站,类似以下内容:

I have 3 TLD's for a site, similar to the following:

  • www.domain.com
  • www.domain.org
  • www.domain.net

它们都位于同一目录下。

我想设置了301重定向,使得.ORG和.NET点到各自的网页上的所有网页的.COM位置。

I would like to set up 301 redirects so that all pages of the .org and .net point to their respective pages at the .com location.

例如,domain.net/topic/page~~V以及www.domain.net/topic/page应该永久重定向到www.domain.com/topic/page~~V。

For example, domain.net/topic/page as well as www.domain.net/topic/page should permanently redirect to www.domain.com/topic/page.

目前,我使用的是code以下,只重定向.net和.org主页到.COM首页。

Currently, I am using the code below which only redirects the .net and .org home pages to the .com home page.

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteRule .?$ http://www.domain.com%{REQUEST_URI} [R=301,L]

感谢您的时间,

凯西

推荐答案

这一个是基于与小的修改你的例子:

This one is based on your example with minor modification:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [R=301,NE,L]

NC R = 301 是pretty的明显。该 NE 是没有逃逸,并$被转义两次p $ pvents查询字符串变量。该 ^(。*)并不在多数情况下需要一个 /

NC, R=301 and L are pretty obvious. The NE is for no-escape and it prevents query string variables from being escaped twice. The ^(.*) does not need a / in most cases.

注:301永久重定向响应将由浏览器,清除浏览器缓存飘飞而测试缓存。否则,你可能看不到你修改的结果。

Note: 301 permanent redirect responses will be cached by the browser so clear your browser cache every now and then while testing. Otherwise you may not see the result of changes you make.

这篇关于重定向1 TLD的另一个所有页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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