[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [users@httpd] Rewrite with proxy adds document root

Thanks Eric,

But if I have multiple rewrite rules and rewrite conditions, how do I speficy for which cond and rule I want to apply it in context of a URI ?

Would waterfall work here ?

For example in one config:

RewriteCond %{QUERY_STRING} ^123 [NC]
RequestHeader set "X-API-KEY" "proxied"
RewriteRule ^/123/(.*) "https://${HOST}$1" [QSD,P,L]

RewriteCond %{QUERY_STRING} ^456 [NC]
RequestHeader set "X-API-KEY” “different-api-key"
RewriteRule ^/456/(.*) "https://${HOST}$1" [QSD,P,L]

Thanks !

On 24 Sep 2018, at 16:28, Eric Covener <covener@xxxxxxxxx> wrote:

On Mon, Sep 24, 2018 at 11:14 AM David Tkacik
<dtkacik@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I have this config included via Include conf.d/myconfig/*.conf within my virtualhost.

<Location "/requested-uri">
ProxyAddHeaders off
RewriteEngine on
RewriteCond %{QUERY_STRING} ^123 [NC]
RequestHeader set "X-API-KEY" "proxied"
RewriteRule (.*) "https://${HOST}$1" [QSD,P,L]

But the above rule is also proxying the /var/www/html which is the document root. I have no idea why as this is not added via .htaccess

So if you curl for example /requested-uri/123/index.html the proxied path would look /var/www/html/requested-uri/123/index.html

Any ideas why ?

Thanks a lot !

It's best to avoid Rewrite inside <Location>.  You could simply match
the URL's you want to match in the first arg of the rewriterule.

Eric Covener

To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx