Answer the question
In order to leave comments, you need to log in
How to allow access by certain URI parameters in htaccess?
Hello,
I have a task to allow access to a folder only using some list of tokens, for example
domain.com/?token=111
I can list tokens in a similar way
RewriteCond %{QUERY_STRING} \.png
RewriteCond %{QUERY_STRING} token=1 [OR]
RewriteCond %{QUERY_STRING} token=2 [OR]
RewriteRule .+ $0
RewriteCond %(QUERY_STRING) .
RewriteRule .+ $0 [env=ALLOW_IT:no]
RewriteCond %{ENV:ALLOW_IT} no
RewriteRule ^(.*) - [F]
RewriteCond %(QUERY_STRING) .
RewriteRule .+ $0 [env=ALLOW_IT:no]
RewriteCond %{QUERY_STRING} .
RewriteRule .+ $0 [env=ALLOW_IT:yes]
RewriteCond %{ENV:ALLOW_IT} no
RewriteRule ^(.*) - [F]
Answer the question
In order to leave comments, you need to log in
all in all, problem solved.
RewriteCond %(REQUEST_URI) .*
RewriteRule .+ $0 [env=ALLOW_IT:no]
RewriteCond %{REQUEST_URI} \.png
RewriteRule .+ $0 [env=ALLOW_IT:yes]
RewriteCond %{QUERY_STRING} token=1
RewriteRule .+ $0 [env=ALLOW_IT:yes]
RewriteCond %{QUERY_STRING} token=2
RewriteRule .+ $0 [env=ALLOW_IT:yes]
RewriteCond %{ENV:ALLOW_IT} no
RewriteRule ^(.*) - [F]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question