Home Vhost Mod Rewrite Negate RewriteCond + ProxyPass
Reply: 0

Vhost Mod Rewrite Negate RewriteCond + ProxyPass

user1405
1#
user1405 Published in May 22, 2018, 11:47 am

(Apache 2.4) I have an SPA at /index.html. I am trying to proxy requests to /api* through a local Node.js server. My expectations are

  1. /index.html will serve the index.html file
  2. /api* will NOT be redirected to index.html; the ProxyPassMatch will serve the content from localhost:65331
  3. Any request to any other non-existant filename/directory will cause /index.html to be served

This is what my vhost file looks like:

RewriteEngine On

ProxyPassMatch ^/api(/(.+))?$ http://localhost:65531/$2

<Directory "/path/to/public/html">
    RewriteBase /

    RewriteRule ^index\.html$ - [L]

    RewriteCond %{REQUEST_URI} !^/api    # This isn't working
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
</Directory>

1 and 3 above are working fine, but 2 is failing. Even with this condition in place

RewriteCond %{REQUEST_URI} !^/api 

I am still seeing /index.html served when requesting something like /api/some/resource

I have also tried omitting the leading slash.

RewriteCond %{REQUEST_URI} !^api 

Can someone point out where I'm going wrong?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.492388 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO