Question
Nginx showing homepage on all URLs
I’m trying to deploy this PHP app that was developed by a third-party web developer. I have no idea how exactly this was written so the nginx configuration file I’m using isn’t working. When I access the root URL (www.example.com), it shows the homepage fine but none of the functionalities on the homepage work. For example, clicking on the Search changes the URL to the query - www.example.com/search?limit_s=0&limit_e=10 but it doesn’t lead to the search result page. The homepage just refreshes.
The same happens for other pages as well. There’s a button for creating new blog posts. If I click on that, the URL changes to https://example.com/make-an-entry but it just refreshes the homepage, doesn’t lead me to the page for creating new posts.
This is the nginx config I’m using currently:
server {
server_name example.com www.example.com;
root /var/www/html/example;
index index.php index.html index.htm;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$query_string;
#try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "memory_limit = 1024M";
include fastcgi_params;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 404; # managed by Certbot
}
I’m not exactly allowed to reveal the actual URL right now but if it can’t be helped at all, I can give you the link to visit the site.
Thanks a lot in advance!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×