Joined
·
189 Posts
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 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:
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 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:
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;
# }
#}
}