问题重定向旧域新与Apache和htaccess的 [英] Problems redirecting old domain to new with Apache and htaccess

查看:115
本文介绍了问题重定向旧域新与Apache和htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主页位于www.nazgulled.net,我买了一个新的领域是www.ricardoamaral.net。这两个结构域指向相同的确切服务器

My homepage is located at www.nazgulled.net and I bought a new domain which is www.ricardoamaral.net. Both these domains point to the same exact server.

我有两个问题重定向,我目前的code是这样的:

I'm having two problems with the redirection, my current code is this:

RewriteCond %{HTTP_HOST} ^(www\.)?nazgulled\.net [NC]
RewriteRule ^(.*)$ http://www.ricardoamaral.net/$1 [L]

现在我只是测试,但这个想法是,以取代[L]与[L,R = 301]当我准备好将整个事情,只是让你知道。

For now I'm just testing but the idea is to replace [L] with [L,R=301] when I'm ready to move the whole thing, just so you know.

反正...

1)这不是工作,当我尝试它,我无法访问nazgulled.net,它给了我一个服务器内部错误,我不明白为什么。 。我不明白为什么,因为如果将ricardoamaral.net由google.com,重定向工作得很好:/

1) This is not working, when I try it, I can't access "nazgulled.net", it gives me a "server internal error" and I don't understand why... I don't understand why because if replace "ricardoamaral.net" by "google.com", the redirect works just fine :/

2)我有几个子域,我想重定向一切都在这些呢。我的第一选择是为每个子域添加不同的重写条件/规则,但这需要大量的手工code,如果用户键入一个不存在的一些子域,他们不被重定向它,我也希望这样。

2) I have a few subdomains and I would like to redirect everything in those too. My first choice is to add different rewrite conditions/rules for each of the subdomains but that takes a lot of manual code and if the user types some subdomain that doesn't exist, they don't be redirect it and I also want that.

推荐答案

有关1,你可以使用这样的事情,而不是:

For 1, you can use something like this instead:

<VirtualHost *:80>
  ServerAdmin webmaster@nazgulled.net
  ServerName nazgulled.net
  ServerAlias www.nazgulled.net
  Redirect permanent / http://www.ricardoamaral.net/
</VirtualHost>

我使用了类似的配置,它完美的作品,保留查询参数,路径等。

I use a similar configuration and it works perfectly, keeping query parameters, paths, etc.

关于你自己的重写规则,我要指出,你的可以的失去你的查询参数,如果你不包含QSA。

Regarding your own rewrite rule, I want to note that you may lose your query params if you don't include QSA.

要诊断内部服务器错误,只是看一下你的虚拟主机中提供您的ErrorLog指令的日志文件,或者是全球性的,这取决于您的配置。它应该给你的错误的确切原因。

To diagnose internal server errors, just have a look at the log file provided by your ErrorLog directive within your vhost, or a global one, depending on your configuration. It should give you the exact reason for the error.

这篇关于问题重定向旧域新与Apache和htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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