Forum Moderators: phranque

Message Too Old, No Replies

Infinite loop in .htaccess

Trying to match anything but a question mark

         

ocon

12:22 am on Mar 21, 2011 (gmt 0)

10+ Year Member Top Contributors Of The Month



I'm trying to match a string in my .htaccess file. What I'm trying to match is any character but a question mark and beyond. Basically I want to match:

Example.png
This is a path.svg

But not:
Example.png?x=y
This is a path.svg?a=1&b=2

Right now my code is a little broad so it fails because it has an infinite loop.

RewriteRule ^folder/File:(.*)$ http://www.widget.com/folder/File:$1?x=y [L]

Any help is appreciated.

Thanks

[edited by: jdMorgan at 11:02 pm (utc) on Mar 28, 2011]
[edit reason] [ code ] tag to clarify patterns and URLs. [/edit]

g1smd

12:32 am on Mar 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteRule can see only the path part of a URL request.

To look at the query string you need a preceding RewriteCond looking at the %{QUERY_STRING} variable.

RewriteCond %{QUERY_STRING} !.
matches blank query string (means "not something").

With a domain in the rule target you have coded a 302 redirect.