使用htaccess的重定向所有流量从根到特定的子域页 [英] Use htaccess to redirect all traffic from root to specific subdomain page

查看:129
本文介绍了使用htaccess的重定向所有流量从根到特定的子域页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经运行了一段时间的网站。我有一个博客上的一个子域一段时间。我决定与主站点做掉,只是支持的博客子域。

I have a site that has been up for some time. I had a blog on a subdomain for some time. I have decided to do away with the main site and just support the blog subdomain.

我有一个重定向设置了这一点,但它通过对导致没有发现页面显示的文件的博客携带所有额外的参数。我只是想重定向去索引页不带参数。

I have a redirect setup for this, but it carries all the extra parameters through to the blog which results in a file not found page appearing. I just want the redirect to go to the index page without parameters.

我目前在我的.htaccess文件是这样

What I currently have in my .htaccess file is this

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?(.*)$ "http\:\/\/blog\.foo\.org\/index\.php" [R=301,L]

当我得到一个请求

http://www.foo.org/foo/foo/?module=富

重定向到

http://blog.foo.org/foo/foo/的index.php?模块= foo的

我希望它重定向到 http://blog.foo.org/index.php

推荐答案

您必须指定在更换查询重写原文:

You have to specify the query in the replacement to override the original:

RewriteCond %{HTTP_HOST} !^blog\.example\.org$ [NC]
RewriteRule ^ http://blog.example.org/index.php? [R=301,L]

这篇关于使用htaccess的重定向所有流量从根到特定的子域页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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