navvn
navvn

Reputation: 575

Apache RewriteRule exclude specific path

I have a htaccess file that is redirecting all requests to a index.html. I need it because I have a single page application. I need to exclude one path from it. I was trying different way but no luck so far.

This is my htaccess

RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
  RewriteRule ^ - [L]

  RewriteRule ^ /index.html [L]

path i want to exclude it /user-api than can have multiple params like /user-api?id=123&cro=123

Any idea how I can do this.

Upvotes: 2

Views: 261

Answers (1)

anubhava
anubhava

Reputation: 785128

You can add one OR condition in your first exclusion rule:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/user-api/?$ [NC,OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

RewriteRule ^ /index.html [L]

Upvotes: 1

Related Questions