重定向旧域的子目录通过htaccess的新域的根文件夹 [英] Redirect subdirectory of old domain to root folder of new domain via htaccess

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

问题描述

我已经经历了一些站点重复了就一个字preSS博客并希望得到重定向到新域旧链接。最初,博客是

  olddomain.com/blog/
 

现在的博客是在根级别

  newdomain.com
 

旧域设置为新域的域别名,它不转发。

如果任何人访问该网站

  olddomain.com/blog/
 

我需要重定向到

  newdomain.com/
 

感谢您的帮助。

解决方案
  1. 刚刚创建.htaccess文件并把它夹在你想从重定向 例如把它在 /博客文件夹。

  2. 以下行添加到您的.htaccess文件。

    RewriteEngine叙述在

    的RewriteCond%{} SERVER_PORT 80

    的RewriteCond%{REQUEST_URI}博客

    重写规则^(。*)$ http://www.newside.com/newblog/ $ 1 [R,L]

I have gone through several domain iterations on a wordpress blog and want to get old links redirected to the new domain. Initially the blog was in

olddomain.com/blog/

Now the blog is at the root level of

 newdomain.com

The old domain is set up as a domain alias of the new domain, it is not forwarded.

If anyone visits the site from

 olddomain.com/blog/

I need that to redirect to

 newdomain.com/

Thanks for your help.

解决方案

  1. Just create your .htaccess file and put it in the folder where you want to redirect from e.g put it in the /blog folder.

  2. Add the following lines to your .htaccess file.

    RewriteEngine On

    RewriteCond %{SERVER_PORT} 80

    RewriteCond %{REQUEST_URI} blog

    RewriteRule ^(.*)$ http://www.newside.com/newblog/$1 [R,L]

这篇关于重定向旧域的子目录通过htaccess的新域的根文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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