I will try to be as explicit as possible.
Friends, I am using Nginx as a local server and I have been modifying the urls in a friendly way, but I have a problem, could you help me with this solution? What am I doing wrong?
I inform that all my projects are in the www (localhost) folder
I have managed to make a url remain: http//localhost/miproyecto/producto/1000
Using the following code in nginx.conf:
location /miproyecto/producto/ {
index index.php;
try_files $uri $uri/ /miproyecto/producto/index.php?$args;
}
I also deleted all the extensions of the files.
http//localhost/miproyecto/busqueda.php
A:
http//localhost/miproyecto/busqueda
With the following code:
location / {
index index.php index.html;
try_files $uri $uri.html $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Here comes my problem and I do not know how to fix it (Clarify with Apache works great for me)
Instead of this url:
http//localhost/miproyecto/negocio.php?empresa=nombreEmpresa
I want it to look like this:
http//localhost/miproyecto/nombreEmpresa
I achieved something using this code:
location /miproyecto/ {
if (!-f $request_filename) {
rewrite ^/miproyecto/(.*)+$ /miproyecto/negocio.php?$1;
}
index index.php
}
But my problem here is that now if I enter another url for example:
http//localhost/miproyecto/registro
It does not open the corresponding file, ie it does not open at registro.php
but thinks that I'm sending the word 'registration' as a variable or company name. Nor does it take me the index.php that is, if I put
http//localhost/miproyecto/
It does not redirect me to the index.php file.
And if I modify the code to this:
location /miproyecto/negocio {
index index.php;
rewrite ^/miproyecto/(.*)+$ /miproyecto/negocio.php?$1;
}
If you recognize me the urls that I mentioned before but you can not place it in the form localhost/miproyecto/nombreEmpresa
It does not allow me to do both.