Tech Support Forum banner
Not open for further replies.
1 - 5 of 5 Posts

· Registered
189 Posts
Discussion Starter · #1 · (Edited)
I have an issue on my hands with re-writing url's with nginx.

I am running a LEMP server on Ubuntu 18.04 with flynax classifieds running as my cms (

I am able to open the http://localhost/classifieds/ url w/out any problems, but any links after that are giving me a 404 even though they do exist. If you can suggest anything I can try to resolve this, I appreciate it a lot.

Here's my default (/etc/nginx/sites-available/) config file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    index index.php index.htm index.html;
    root /var/www/html/;
    server_name localhost;

location classifieds {
    index index.php index.htm index.html;
    try_files $uri $uri/ index.php?$args;
    root /var/www/html/classifieds;

#---- flynax rewrite section start ---- #
#non last slash redirect
rewrite ^([^\.]*[^/])$ $1/ permanent;

#personal address subdomains rewrite
if ($host ~ ((?!www\.|m\.|mobile\.).*)\.(.*) ) {
set $subdomain $1;

if ( $subdomain ) {
rewrite ^(.*)$ index.php?page=$subdomain&wildcard&rlVareables=$request_uri last;

if (!-e $request_filename)
#define paging
rewrite ^/([^/]*)/((.*)/)?(index([0-9]*).ht(m?ml?))?$ index.php?page=$1&rlVareables=$3&pg=$5 last;

#define listing details
rewrite ^/([^/]*)/((.*)/)?(.+)-l?([0-9]+).ht(m|ml)$ index.php?page=$1&rlVareables=$3&listing_id=$5 last;

#define browse
rewrite ^/([^/]*)/(.*)(\.html|\.htm|\/)$ index.php?page=$1&rlVareables=$2 last;

#define single pages
rewrite ^/(.+)(\.html|\.htm|\/)$ index.php?page=$1 last;

#sitemap rewrite rules
rewrite ^/([a-z_]*)?sitemap([0-9]*).xml$ /plugins/sitemap/sitemap.php?search=google&number=$2&mod=$1 last;
#---- flynax rewrite section end ---- #

# pass PHP scripts to FastCGI server

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

    # With php-fpm (or other unix sockets):
    # With php-cgi (or other tcp sockets):
    # fastcgi_pass;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    # location ~ /\.ht {
    # deny all;
    # }

# Virtual Host configuration for
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#server {
#    listen 80;
#    listen [::]:80;
#    server_name;
#    root /var/www/;
#    index index.html;
#    location / {
#        try_files $uri $uri/ =404;
#    }


· Registered Member
11 Posts

· Registered
189 Posts
Discussion Starter · #4 ·
You may need to configure the firewall. For example, if a UFW firewall is active on the Ubuntu web server, it may need to be further adjusted to support NGINX.

See this tutorial to enable the traffic that you want via UFW:

You need both OpenSSH & Nginx to have deployed UFW profiles on your Ubuntu systems to enable both HTTP/HTTPS traffic.

Just to be clear, what I mean is that all my links are on localhost, but no matter what they cannot be found 404 error. If I turn off disable mod_rewrite all the the urls become good again, not 404 error so I believe this has nothing to do with ufw, but instead is a mis-configuration in the nginx config file some where.

Thank you though for your answer
1 - 5 of 5 Posts
Not open for further replies.