我想要做的是以下几点:
我的域名xy.example.com不再存在。 因此,我想做一个简单的redirect到新的域abc.example.com。 它应该是一个redirect,当某人在浏览器栏中inputhttp://xy.example.com/team.php时也可以工作 – 比它redirect到http://abc.example.com/team.php
我已经尝试了一些东西,但并没有真正起作用。 我必须在Apache 2configuration中放置什么?
您可以使用RedirectPermanent指令将客户端redirect到新的URL。
只需创build一个非常简单的VirtualHost的旧域,您将其redirect到新的域:
<VirtualHost *:80> ServerName xy.example.com RedirectPermanent / http://abc.example.com/ # optionally add an AccessLog directive for # logging the requests and do some statistics </VirtualHost>
在DocumentRoot创build或编辑.htaccess 。 加
RewriteEngine On RewriteRule ^(.*)$ http://abc.example.com/$1 [R=301,L]
此外,我会将ServerName指令更改为新域,并将旧域的ServerAlias 。
ServerName abc.example.com ServerAlias xy.example.com