开发者

Apache RewriteRule removing submit x y coordinates from Querystring (Mac Snow Leopard OS X)

开发者 https://www.devze.com 2023-01-21 14:21 出处:网络
This ought to be a simple exercise in Apache with mod_rewrite and all of it\'s flexibility. I have verified the Rewrite module is working with full logging but no matter how I shake out my rules and c

This ought to be a simple exercise in Apache with mod_rewrite and all of it's flexibility. I have verified the Rewrite module is working with full logging but no matter how I shake out my rules and conditions, I can't get it to work.

What I want is to rewrite the following url:

http://www.domain.com/search?x=10&y=10&query=search+text

to convert to:

http://www.domain.com/search?query=search+text

... in the location/address bar of the browser so as to remove the stupid x y coordinate values that are there because of an image submit button. Every little bit of url cleansing helps fo开发者_开发知识库r good SEO practices.

Here is what I have in my httpd-vhosts.conf in /etc/apache2/extra folder on Snow Leopard OS X...

RewriteCond %{QUERY_STRING} ^query=(.*)$ [NC]
RewriteRule ^search /search?query=%1? [L]

Any advice would be much appreciated.

Thanks!


you should remove the ^ before the query, otherwise it don't match the x=10&y=10&query=search+text

RewriteCond %{QUERY_STRING} query=(.*)$ [NC]
RewriteRule ^/search /search?query=%1? [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号