Answer the question
In order to leave comments, you need to log in
How to give access to a directory without a slash?
Hello.
You need to create a directory for api on the server, for the api itself, the request looks like this "site.com/api/data", but my address looks like this "site.com/api/data/". That is, I have index.php in the data folder, which is responsible for the directory, but the api cannot send a request for this file, showing the request status "301 Moved Permanently".
Help me please.
Answer the question
In order to leave comments, you need to log in
Try like this:
#
# Добавить слеш
#
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
#
# Удалить слеш
#
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question