重定向子域名,并保留URL结构 [英] redirect subdomain and retain url structure

查看:280
本文介绍了重定向子域名,并保留URL结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重定向一个字preSS博客,住在subdomin到我的根。当我访问从我的旧博客的链接,他们只是重定向到我的博客索引页面,但我需要他们重定向到实际岗位。例如 -

I'm redirecting a wordpress blog that lived in a subdomin to my root. when i visit links from my old blog, they just redirect to the index page of my blog, but i need them to redirect to the actual post. for example -

sub.mysite.com/1/2/3 - should redirect to -  mysite.com/sub/1/2/3

如何才能做到这一点?谢谢!

how can this be done? thanks!

更新 - 仍然没有找到一个解决方案。有人吗?

UPDATE - still haven't found a solution for this. Anyone?

或有另一篇文章在这里已经存在,会告诉我这样做的正确方法?谢谢!

OR is there another post here that already exists that will show me the correct way to do this? THANKS!

推荐答案

另一种方法是通过编辑Web服务器的配置。

The alternative approach is by editing your web server configuration.

Apache的改写可以做到这一点的规则。你最有可能在你的博客的根目录下的.htaccess文件。下面附加给它的文本。如果没有这样的文件,创建一个。

Apache's rewrite rules can do this. You most likely have a .htaccess file in the root directory of your blog. Append the text below to it. If there is no such file, create one.

RewriteEngine On
RewriteCond %{HTTP_HOST} sub.mysite.com
RewriteRule ^(.*)$ http://mysite.com/sub$1 [R=permanent,L]

您的Web服务器必须配置为接受来自.htaccess文件此配置。它也可以被安置在直接的配置。这个步骤会因您的虚拟主机上。

Your web server has to be configured to accept this configuration from a .htaccess file. It can also be placed in the configuration directly. The procedure for this differs depending on your web host.

这篇关于重定向子域名,并保留URL结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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