Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Apache newb here.

Ultimate goal is use Apache as a reverse proxy (got that working) and append a particular value to a query string (can't get it working) via mod-rewrite.

The string in question is:

http://localhost:9089/views/JavaScriptTarget/Dashboard

...to which I want to append ?Category=Furniture:

http://localhost:9089/views/JavaScriptTarget/Dashboard?Category=Furniture

I have enabled the module:

#LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule sed_module modules/mod_sed.so

I have attempted to enable rewrite logging in a number of places:

<Directory />
    Options All
    AllowOverride All
    LogLevel debug rewrite:trace8
    RewriteEngine On    # Turn on the rewriting engine
    RewriteRule    ^Dashboard$    Dashboard?Category=Furniture    [NC]
</Directory>

...and:

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel debug rewrite:trace8

...in both cases, I see no mentions of [rewrite] in error.log

Finally, here is the section of httpd.conf with the rewrite rule itself and the reverse proxy stuff:

<Directory />
    Options All
    AllowOverride All
    LogLevel debug rewrite:trace8
    RewriteEngine On    # Turn on the rewriting engine
    RewriteRule    ^Dashboard$    Dashboard?Category=Furniture    [NC]
</Directory>

#####Proxy Rule
ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass / http://server8/
ProxyPassReverse / http://server8/

When I execute the string http://localhost:9089/views/JavaScriptTarget/Dashboard I am correctly redirected to http://server8/views/JavaScriptTarget/Dashboard...but ?Category=Furniture is not being appended.

Any clue what's I'm doing wrong here? I'm at wit's end. Can't even get to the point where I can get the rewrite errors to show up in logs!

I'm on 2.4.4 on Windows x64 (Win7), btw...

share|improve this question
    
I've never used it but I wonder if this is what the [P] mod_rewrite flag is for? httpd.apache.org/docs/2.4/rewrite/proxy.html –  DerfK Apr 18 '13 at 23:36
    
I think ^Dashboard$ matches only the exact URL Dashboard. Your's might begin with a slash or even be /views/JavascriptTarget/Dashboard. Try Dashboard$ instead (means your URL ends with Dashboard). –  mimipc Apr 18 '13 at 23:57

1 Answer 1

up vote 2 down vote accepted

Your RewriteRule "^Dashboard$" means that the URL string has nothing before and nothing after "Dashboard". Is that what you want? Seems like your URL is "/views/JavaScriptTarget/Dashboard".

Maybe it does not matter but I wouldn't put the RewriteRule in the configuration - on the "Directory" directive I'm no expert as I mostly use Apache for reverse proxy and I just don't end up using it.

So, all this will be ultimately proxied to your backend server "server8". Again make sure on your server8 that you have nothing that does redirect using the server's host name. You can do redirects with "/" but not with "{servername}/" if you see what I mean.

I would set the following configuration to achieve what you want.

RewriteEngine On
RewriteRule    ^/views/JavaScriptTarget/Dashboard    /views/JavaScriptTarget/Dashboard?Category=Furniture [PT]


ProxyPass / http://server8/
ProxyPassReverse / http://server8/
share|improve this answer
1  
I would indeed advise not to put the RewriteRule in a Directory context. Just put it in the server context. RewriteRules in a Directory context are treated like rules in .htaccess files, they always result in an extra internal redirect. –  Krist van Besien Apr 19 '13 at 6:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.