P
P
P4YK2021-08-25 11:26:35
Nginx
P4YK, 2021-08-25 11:26:35

How to hide folder path in nginx url?

Good afternoon! Tell me how to hide the path to the folder in the url. Now I have it like this http://domain.ru/main/help.php , and I need http://domain.ru/help.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-08-25
@dodo512

If only a few files are needed in the /main/ folder. If you need to specify a different root for all php files.
rewrite ^/(help|file1|file2)\.php$ /main/$1.php;

location ~ \.php$ {
    root /var/www/main;
    
    fastcgi_pass ...;
    include fastcgi_params;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question