I'm using Joomla/MariaDB and another CMS/PostgreSQL in the same server with Nginx as web server. The rewriting rules for joomla works as well, but doesn't work for the other one. The URL's structures from the PostgreSQL CMS looks like this:
http://example.com/dir/Something.php?somename=Blah_Setup/Otherstring.php
http://example.com/dir/Something.php?somename=Blah_Setup/Otherstring.php&new_blah=true
http://example.com/dir/Something.php?somename=Blah_Setup/Otherstring.php&include=General_Info&worker_id=new
This is what I have:
location /sis/ {
rewrite ^(/sis)/Modules.php?modname=(.*/)\..*$ $1/$2 last;
}
Can anyone point out where I'm going wrong, please?
There are two problems with your rewrite rule:
location /sis/
does not process URIs ending with .php
, so they will never see your rewrite rule?
onwards) is not considered as part of the rewrite patternYou can easily extract the value of the modname
parameter by using the predefined variable $arg_modname
.
If all of the /sys/Modules.php
URLs need to be rewritten, the solution is easily accomplished with an exact match location:
location = /sis/Modules.php {
rewrite ^ /sis/$arg_modname last;
}
If only those URIs with an $arg_modname
require a rewrite, you will need to wrap it inside an if ($arg_modname) { ... }
block. But it does increase complexity so a simple example is more difficult to provide without seeing your entire server configuration.