使用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]