Y
Y
Yaroslav Alekseenko2018-12-03 20:19:52
Nginx
Yaroslav Alekseenko, 2018-12-03 20:19:52

How to redirect all directories and non-existing files to file.php?

Good afternoon,
I understand the Nginx settings. The question is how to repeat this setting in nginx:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ __/index.php [L,QSA]

Those. if we are accessing a file, then we open the file, and in all other cases /folder/file.php? Note that the file to be redirected to is not in the root of the home folder.
Redirecting everything is easy enough: Redirect
rewrite ^ /__/index.php last;
"not existing" too:
try_files $uri $uri/ /__/index.php?$args;
But I need a check like this:
if (is_directory || !is_file) { rewrite ^ /__/index.php last; }

Thank you colleagues for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-12-03
@webdevfan

try_files $uri /__/index.php?$args;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question