N
N
Nikita2021-01-22 14:33:38
htaccess
Nikita, 2021-01-22 14:33:38

How to restrict access to the site by cookie through .htaccess?

Current .htaccess

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


How to deny access to the site if the cookie (for example, auth) is not equal to a certain value (for example, ok)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-01-22
@dodo512

ErrorDocument 403 /403.html

RewriteEngine on

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_COOKIE}  !auth=ok
RewriteRule ^ - [F]

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question