0

I have a CRA app with a subdirectory where I have a CMS system. I need to redirect every request to the domain to index.html except ###.com/cms, which needs to normally work to allow accessing the API.

I have .htaccess as such:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

I tried adding RewriteCond %{REQUEST_URI} ^/cms/?$ [NC] as per .htaccess - exclude directory from RewriteCond but that didn't wotrk

P Varga
  • 19,174
  • 12
  • 70
  • 108
zver
  • 33
  • 3
  • Using this also didn't work: https://stackoverflow.com/questions/1848500/htaccess-mod-rewrite-how-to-exclude-directory-from-rewrite-rule – zver May 04 '19 at 06:52
  • To exclude you need to use a negitive condition `RewriteCond %{REQUEST_URI} !^/cms/?$ [NC]` . You missed the `!` in your RewriteCond – Amit Verma May 04 '19 at 07:33

1 Answers1

0

The simplest way to achieve this is:

Create .htaccess file in your cms directory

add only following line:

RewriteEngine Off

Irshad
  • 67
  • 6