Rewrite URLs for Sub Server on NGINX

4 posts / 0 new
Last post
#1 Tue, 07/04/2017 - 22:51
DreamStage

Rewrite URLs for Sub Server on NGINX

Hello my old apache rewrite URL rules are not working for nginx (as expected)

Options -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

I've tried this: https://winginx.com/en/htaccess and edited my configuration at /etc/nginx/sites-available/sub server domain config file but didn't worked. The problem is when i access sub domain it downloads the php files instead executing them.

Later i've followed this: http://nginxlibrary.com/wordpress-permalinks/ and still no solution

This is required for my IP Board Forum's Friendly Urls

Tue, 07/04/2017 - 23:12
unborn
unborn's picture

hi, as this have nothing to do with virtualmin it self, you can have look here: https://www.nginx.com/blog/converting-apache-to-nginx-rewrite-rules/

Configuring/troubleshooting Debian servers is always great fun

Tue, 07/04/2017 - 23:28
DreamStage

But which config file i add these rules, to the default one or the sub server domain config file? As i want this for the sub server domain ofc

Default has: location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; }

And sub server domain has: location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/var/php-nginx/numbers.sock/socket; }

And btw inside server { tag there is a location tag aswell. Do i set it there or a new location configuration outside?

Wed, 07/05/2017 - 00:39
DreamStage

Solved by adding a new location block instead replacing the current one

Topic locked