htaccess的301重定向与查询 [英] htaccess 301 redirect with query

查看:149
本文介绍了htaccess的301重定向与查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个htaccess重定向与查询就像这样:

 重定向301 /?页=服务/ branddevelopment /品牌的发展?

或本

 的RewriteCond%{QUERY_STRING} ^页=服务/ branddevelopment $
(。*)重写规则^ $的http://域名/ [R = 301,L]

我失去了在这里的东西吗?或错误的语法?它不重定向我希望它的方式。谢谢!


解决方案

  

我失去了在这里的东西吗?或错误的语法?它不会重定向
  我希望它成为的方式。谢谢!


您真的没有解释对所发生的事情,结果你得到,从而使他人可以告诉你为什么让你得到的结果。

然而,在一般的你不能使用 mod_alias中(重定向)来重定向查询字符串将无法正常工作。

您必须使用的mod_rewrite ,它好像你试图做。然而,你不希望结转查询字符串的重定向,所以你需要重写URL中使用

所以,如果你有像这样的URL

  http://www.example.com/?page=services/branddevelopment

那么你的规则是

 的RewriteCond%{QUERY_STRING} ^页=服务/ branddevelopment $
重写规则^(。*)$ http://domain.com/? [R = 301,L]

I'm trying to setup an htaccess redirect with query just like this:

Redirect 301 /?page=services/branddevelopment /brand-development?

or this:

RewriteCond   %{QUERY_STRING}   ^page=services/branddevelopment$
RewriteRule   ^(.*)$ http://domainname/   [R=301,L]

Am I missing something in here? Or a wrong syntax? It doesn't redirect the way I want it to be. Thanks!

解决方案

Am I missing something in here? Or a wrong syntax? It doesn't redirect the way I want it to be. Thanks!

You really didn't explain much about what is happening and the result you are getting so that someone can tell why you are getting the result you are getting.

However in general you can't use mod_alias (Redirect) to redirect a query string it won't work.

You have to use mod_rewrite, which it seems like you were trying to do. However you don't want to carry over the query string with the redirect so you need to use ? in the rewrite URL.

So if you have a URL like so

http://www.example.com/?page=services/branddevelopment

Then your rule would be

RewriteCond %{QUERY_STRING} ^page=services/branddevelopment$
RewriteRule ^(.*)$ http://domain.com/?   [R=301,L]

这篇关于htaccess的301重定向与查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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