Answer the question
In order to leave comments, you need to log in
How to define empty REQUEST_URI?
The bottom line is:
1) There is a website. Let's say example.com
2) You can access the main page in two versions: example.com and example.com/ (slash at the end)
3) You need to redirect from example.com to example.com/.
4) Actually the question is how to do this using htaccess and is it even possible? As I understand it, request_uri cannot be empty, so in both cases it is equal to a slash (/)
Answer the question
In order to leave comments, you need to log in
# remove trailing slash
RewriteRule ^(.*)/$ /$1 [L,R=301]
# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L, R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question