Answer the question
In order to leave comments, you need to log in
How to redirect ajax requests to .htaccess?
The site is divided into backend and frontend, communication takes place through Ajax requests. A single entry point is used, for the front index.html and for the back handler api.php
I'm not a master of composing .htaccess, I pieced it together:
AddDefaultCharset utf-8
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^\frontend/scripts/*
RewriteCond %{REQUEST_URI} !^\frontend/styles/fonts/*
RewriteCond %{REQUEST_URI} !^\frontend/images/*
# if it is ajax request
RewriteCond %{HTTP:X-Requested-With} XMLHttpRequest
RewriteRule . api.php [L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question