我正在寻找从旧域迁移到新域。
我有我的旧域olddomain.com和新的域newdomain.com现在指向相同的IP地址。
我有Apache服务器就地处理请求。
我如何301 redirect我的所有
为什么我的子域名redirect到我的主域名?
htaccess if语句
htaccess重写传递两个variables或一个取决于如果两者都可用?
清理URLredirect循环
olddomain.com/*
&
www.olddomain.com/*
至
newdomain.com/*
我可以得到确切的正则expression式或configuration,我需要在htaccess添加。
我的newdomain.com和olddomain.com都是由相同的IP从相同的IP服务器,所以“/”redirect可能导致周期? 所以寻找有效的方法
我试过了
<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>
甚至尝试添加虚拟主机
RedirectMatch (.*).jpg$ http://comp17$1.jpg
但是,当我在浏览器中打本地主机到我的计算机名称,即comp16时,它不会redirect站点
.htaccess基于HTTP_REFERER的redirect是空的
什么改变.htaccess所以它停止显示子域
.htaccess平面链接的重写规则
如何在使用htaccess 404redirect时查找引荐url?
在每个olddomain.com主机的配置( VirtualHost )中试试这个:
Redirect permanent / http://newdomain.com/
重定向的Apache文档 。 这是所有应该重定向的首选方式。 如果你必须使用mode_rewrite/htaccess那么在这个上面有很多的问题,其中之一就是:
编辑
Apache关于简单重定向的建议 :
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.
将下面的代码写入到.htaccess中,它会将所有旧域请求重定向到新域。
RewriteEngine on RewriteBase / RewriteRule (.*) http://newdomain.com/$1 [R=301,L]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。