Answer the question
In order to leave comments, you need to log in
How to properly redirect address in .htaccess?
It is necessary to make it so that if the request goes to / api then redirect to index.php,
if you just went to the site then to index.html
Here are the files in the folder
and here is what I wrote in the htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api index.php [L]
</IfModule>
Answer the question
In order to leave comments, you need to log in
1. change the priority of the forced index file to html, as a rule php has a higher priority
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api index.php [L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question