Amo*_*kar 11 apache .htaccess http-status-code-301
我希望从旧域迁移到新域.
我现在有我的旧域olddomain.com和新域newdomain.com指向相同的IP地址.
我有Apache服务器就地处理请求.
我怎么301 redirect都是我的
olddomain.com/*
Run Code Online (Sandbox Code Playgroud)
&
www.olddomain.com/*
Run Code Online (Sandbox Code Playgroud)
至
newdomain.com/*
Run Code Online (Sandbox Code Playgroud)
我可以获得需要添加的精确正则表达式或配置吗htaccess?
我的newdomain.com和olddomain.com都是由来自同一IP的同一个apache服务,所以"/"重定向可能导致循环?所以寻找有效的方式
我试过了
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost$ [OR]
# RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://comp16/$1 [R=301,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
甚至尝试添加虚拟主机
RedirectMatch (.*)\.jpg$ http://comp17$1.jpg
Run Code Online (Sandbox Code Playgroud)
但是当我在浏览器中将localhost命到我的计算机名称即comp16时,它不会重定向站点
Qbe*_*ben 17
在VirtualHost每个olddomain.com主机的配置()中试试这个:
Redirect permanent / http://newdomain.com/
Run Code Online (Sandbox Code Playgroud)
Redirect的Apache文档.这是所有应重定向的首选方式.如果你必须使用,mode_rewrite/htaccess那么围绕这个有很多问题,其中一个是:
如果第一个域具有文件夹路径,我如何301将一个域重定向到另一个域
Apache关于简单重定向的EDIT建议:
mod_alias provides the Redirect and RedirectMatch directives, which provide a means to
redirect one URL to another. This kind of simple redirection of one URL, or a class of
URLs, to somewhere else, should be accomplished using these directives rather than
RewriteRule. RedirectMatch allows you to include a regular expression in your
redirection criteria, providing many of the benefits of using RewriteRule.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34078 次 |
| 最近记录: |