Please use this template for troubleshooting questions.
My issue:
When I enter the URL for my site and press Enter, a phantom directory is added between the hostname and the index.php.
How I encountered the problem:
I am hosting multiple sites on a FreeBSD 14 server. I had a working config where http://server.dns.alias
took me to my wiki site. I decided to change the nginx config so that all of the sites fell under subdirectories using the true server name (ex. http://trueservername/site
). It worked for a static site, but not for my wiki (This is a different problem, I think). After troubleshooting this for a while, I gave up and reverted to the original config.
Now, with the original working config in place, when I go to http://server.dns.alias
, it turns the URL into http://server.dns.alias/wiki
. I have searched my config and LocalSettings.php (Mediawiki) and I cannot find why this is happening.
Solutions I’ve tried:
Restarting nginx (service nginx restart), forcing the use of the correct config file (nginx -f nginx.conf). I have tried debugging nginx and my error logs are not giving any more useful info.
Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric):
nginx version: nginx/1.28.0
Deployment environment:
FreeBSD 14.3 jail hosted on a FreeBSD 14.3 server
Mediawiki 1.43
PHP 8.4.10 (fpm-fcgi)
Minimal NGINX config to reproduce your issue (preferably running on https://tech-playground.com/playgrounds/nginx for ease of debugging, and if not as a code block): (Tip → Run nginx -T
to print your entire NGINX config to your terminal.)
server {
listen 80;
server_name mwiki;
#access_log logs/host.access.log main;
root /usr/local/www/mediawiki;
index index.php;
location / {
try_files $uri $uri/ @mediawiki;
}
location @mediawiki {
rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx
directory.)
192.168.1.246 - - [06/Sep/2025:18:46:50 -0400] "GET /wiki/index.php?title=Main_Page HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 Ddg/18.6"
192.168.1.246 - - [06/Sep/2025:19:13:30 -0400] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 Ddg/18.6"
192.168.1.246 - - [06/Sep/2025:19:13:30 -0400] "GET /wiki/index.php?title=Main_Page HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15 Ddg/18.6"