I want to do a custom rewrite
for the subdomain on ISPconfig. When I add the code below for this, the subdomain is redirected to the main domain.
Sample #1:
server {
...
if ($http_host = "panel.example.com") {
rewrite ^(?!/(_SubDomains/Panel|stats|\.well-known/acme-challenge))/(.*)$ /_SubDomains/Panel/$2 last;
rewrite ^/(.*)/(.*)$ /index.php?cmd=$1&scd=$2? last;
}
...
}
If I do as in example two, Nginx server does not work.
Sample #2:
server {
...
if ($http_host = "panel.example.com") {
rewrite ^(?!/(_SubDomains/Panel|stats|\.well-known/acme-challenge))/(.*)$ /_SubDomains/Panel/$2 last;
location ~ \.php$ {
rewrite ^/(.*)/(.*)$ /index.php?cmd=$1&scd=$2? last;
}
}
...
}
I was using in Apache server like this:
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !\.php$ [NC]
RewriteCond %{REQUEST_URI} [^/]$
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteCond %{REQUEST_URI} !.(css|gif|ico|jpg|js|png|swf|txt)$
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)?$ index.php?cmd=$1&scd=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?cmd=$1 [L,QSA]
</IfModule>
Without rewrite link: https://panel.example.com/index.php?cmd=abc&scd=xyz
With Rewrite: https://panel.example.com/abc?scd=xyz
How can I use it on Nginx PHP-FPM server like I use it on Apache server in subdomain?