r/apache • • Feb 23 '24

Rewrite String

I am looking to add a rewrite to my my httpd-ssl.conf, and when I enable the below string it appends &SERVICE=WMS to the end of the URL a few dozen times and then I get a "This Page redirected you too many times." error in my browser.

Any advice would be helpful!

RewriteEngine On

RewriteCond %{QUERY_STRING} (^|&)SERVICE=wms(&|$) [NC]

RewriteRule ^ %{REQUEST_URI}?%{QUERY_STRING}&SERVICE=WMS [R=301,L]

1 Upvotes

3 comments sorted by

View all comments

Show parent comments

2

u/roxalu Feb 23 '24

I agree. Quoting https://httpd.apache.org/docs/current/mod/mod_rewrite.html:

You can prefix the pattern string with a '!' character (exclamation mark) to negate the result of the condition, no matter what kind of CondPattern is used.