Apache negative regex for LocationMatch

apache-2.2

I have the following Location directives in my httpd.conf:

<Location /App1>
    SetHandler weblogic-handler
    WebLogicHost 1.2.3.4
    WeblogicPort 7003
</Location>

<Location /App2>
    SetHandler weblogic-handler
    WebLogicHost 1.2.3.4
    WeblogicPort 7004
</Location>

<Location /Dev>
    SetHandler weblogic-handler
    WebLogicHost 1.2.3.4
    WeblogicPort 7005
</Location>

Now I want any requests made to a path that is != /App1 or /App2 to have the same settings as the /Dev location.

something like

<LocationMatch "/^(?!App?).*\./*">
    SetHandler weblogic-handler
    WebLogicHost 1.2.3.4
    WeblogicPort 7005
</LocationMatch>

Would seem like a suitable solution, but it doesn't seem to work. Any ideas?

Best Answer

Here's the solution:

<LocationMatch "/*">
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !Dev
    RewriteCond %{REQUEST_URI} !App1
    RewriteCond %{REQUEST_URI} !App2

    RewriteRule ^(?!Dev)(?!App1)(?!App2)(.+) http://LINK-TO-DEV/ [L,R=301]
</LocationMatch>
Related Topic