简体   繁体   English

htaccess 301使用查询重定向

[英]htaccess 301 redirect with query

I'm trying to setup an htaccess redirect with query just like this: 我正在尝试使用查询设置htaccess重定向,如下所示:

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. 但是一般来说,您不能使用mod_alias (重定向)来重定向无法使用的查询字符串。

You have to use mod_rewrite , which it seems like you were trying to do. 您必须使用mod_rewrite ,似乎您正在尝试这样做。 However you don't want to carry over the query string with the redirect so you need to use ? 但是,您不想通过重定向保留查询字符串,因此需要使用? in the rewrite URL. 在重写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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM