Go Back   Tech Support Forum > Design Forum > Web Serving and Management

User Tag List

Re-writing URLs with Nginx...

This is a discussion on Re-writing URLs with Nginx... within the Web Serving and Management forums, part of the Tech Support Forum category. I have an issue on my hands with re-writing url's with nginx. I am running a LEMP server on Ubuntu


Closed Thread
 
Thread Tools Search this Thread
Old 10-05-2018, 03:47 PM   #1
Registered Member
 
Join Date: Sep 2011
Posts: 162
OS: Ubuntu Linux


Question

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 (flynax.com)


I am able to open the https://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:

Code:
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 127.0.0.1:9000;
              }









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









# Virtual Host configuration for example.com
#
# 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 example.com;
#
#    root /var/www/example.com;
#    index index.html;
#
#    location / {
#        try_files $uri $uri/ =404;
#    }
#}

}
Brian07002 is offline  
Sponsored Links
Advertisement
 
Old 10-06-2018, 06:40 PM   #2
Registered Member
 
Join Date: Sep 2011
Posts: 162
OS: Ubuntu Linux



Anyone?
Brian07002 is offline  
Old 12-06-2018, 06:45 PM   #3
Registered Member
 
Join Date: Dec 2018
Posts: 11
OS:



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:

https://hostadvice.com/how-to/how-to-install-the-lemp-nginx-mariadb-and-php-stack-on-ubuntu-18-04-lts/

You need both OpenSSH & Nginx to have deployed UFW profiles on your Ubuntu systems to enable both HTTP/HTTPS traffic.
scriptbox is offline  
Sponsored Links
Advertisement
 
Old 12-06-2018, 07:25 PM   #4
Registered Member
 
Join Date: Sep 2011
Posts: 162
OS: Ubuntu Linux



Quote:
Originally Posted by scriptbox View Post
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:

https://hostadvice.com/how-to/how-to-install-the-lemp-nginx-mariadb-and-php-stack-on-ubuntu-18-04-lts/

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

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
Brian
Brian07002 is offline  
Old 12-06-2018, 09:21 PM   #5
Registered Member
 
Join Date: Dec 2018
Posts: 11
OS:



Can you go through the steps here to check your NGINX installation? There is a sample copy of the nginx.conf file for reference:

+ https://hostadvice.com/how-to/how-to-tune-and-optimize-performance-of-nginx-web-server/

Also review the configuration settings for worker processes, connections, & multi-accept values.
scriptbox is offline  
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Firefox did not recover previous opened URLS!
I really need help guys. Im data mining and I had a lot of urls opened. Im doing research on each site. Saving all the info in google drive - spreadsheet also open. Id say 20 urls were open. Firefox crashed so I had to restart it. But it did not recover all the urls that were previously opened. A...
goranwebdev Mozilla/Firefox Browsers 0 02-11-2015 05:09 AM
[SOLVED] VIRUS????
Hello, Could someone PLEASE help me? I'm getting a lot of page 404 error, "Welcome to nginx!" when trying to load a page from my bookmark or even a simple search result from Google. Thank you very much for your time!!!!!! ***************************** . DDS (Ver_2011-08-26.01) -...
bcdinh Resolved HJT Threads 48 03-19-2012 06:33 PM
500 internal server error nginx & 404 not found nginx?
Hello: This is my first post. I also posted this on yahoo answers; I really need a quick resolution to this problem, as it effects my work-at-home job and thus my wallet. Iíve been having this crap problem that just seemed to popup out of no-where for two days now. I use both mozilla...
cpl. kindel Internet Explorer & Edge Forum 5 02-09-2012 06:38 PM
Problem when writing and mouse "click"?
I have this problem: When i open some editor for writing, for example word, and there is a dash blinking that indicate that i can write a text... When I move mouse over something else, this dash will disappear in 1 or 2 seconds, so i cant write in this word, and i have to click on the text...
Retko Windows 7 , Windows Vista Support 1 01-14-2011 01:52 AM

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2
Powered by vBadvanced CMPS v3.2.3


All times are GMT -7. The time now is 10:34 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
vBulletin Security provided by vBSecurity v2.2.2 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.1.0 (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Copyright 2001 - 2018, Tech Support Forum

Windows 10 - Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts