Answer the question
In order to leave comments, you need to log in
How to send all requests to a single file in nginx?
Greetings.
There is a task to close access for users. Allow your own, send strangers to pages on another domain with truncated information.
Now, at the cost of a million trial and error, this solution turned out, in nginx :
location / {
root "%hostdir%";
rewrite ^(.*)$ /redirect.php;
}
location /x/ {
alias "%hostdir%";
try_files $uri /index.php?$args;
internal;
rewrite ^/x//list_autors/(.*)$ /index.php?g=$1 last;
rewrite ^/x//posts/(.*)$ /index.php?q=$1 last;
}
if (!$user) {
#здесь редиркт если не наш пользовалель
} else {
header("X-Accel-Redirect: /x/".$_SERVER["REQUEST_URI"]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question