C
C
codpr102020-08-13 09:49:51
Nginx
codpr10, 2020-08-13 09:49:51

Nginx, how to change link address via location, rewrite, alias?

There is a server on centos 6 + nginx + php-fpm
On the server there is a site on the engine, in which plugins are located in a folder like:
https://site.com/plugins/plugin_name/folder/plugin.php
You need to remove the url part to make this page and other plugin pages opened at
https://site.com/plugin_name/plugin.php
but without transferring the folder itself.

I read a lot of information about configuring Nginx but nothing works.
So, the Nginx file (nginx.conf) is located on the server in the
/etc/nginx folder.
At the moment, settings have been made that prohibit loading the site by IP

http {
server {
listen ip: 80 default_server;
listen ip:443 default_server;
server_name_;
return 444;
}
}

Next, in the same server section, I wrote
location /plugin_name {
alias /home/admin/web/site.com/public_html/plugins/plugin_name/folder;
}
Then, of course, I restarted Nginx and php-fpm, but nothing works.

I also tried this design, it also does not work
location /plugin_name {
rewrite ^/.* http://$server_name/plugins/plugin_name/folder permanent;
}

I ask for help from knowledgeable people how to solve the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question