Don't get a "NOT FOUND" pattern working

Oh, the strange things mod_rewrite does!

Don't get a "NOT FOUND" pattern working

Postby mephistho » Mon Aug 25, 2008 2:08 am

Hi there,

I'm confused, I tried several possibilities. All I want is to redirect all cgi-requests that DO NOT contain a certain parameter with all their other parameters to a different directory:

A request of nagios_atlas/extinfo.cgi?type=1&host=atlas_r1 should be redirected to nagios/extinfo.cgi?type=1&host=atlas_r1 because the requested url does not contain the parameter "&atlas".
A request of nagios_atlas/status.cgi?hostgroup=all&style=hostdetail&atlas should not be changed, because it contains "&atlas".

I tried several things, but nothing worked. The last try was:

Code: Select all
ReWriteRule ^nagios_atlas/(.*)(\.cgi)?(.*)!&atlas$ /nagios/%1.cgi?%2

Where is the mistake? I'm thankful for every hint.

Posts: 1
Joined: Mon Aug 25, 2008 1:59 am

Postby richardk » Tue Aug 26, 2008 10:54 am

The query string is matched with the %{QUERY_STRING} variable. Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} !^(.*&)?atlas(&.*)?$ [NC]
RewriteRule ^nagios_atlas(/.+\.cgi)$ /nagios$1 [QSA,L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 1 guest