Hi guys, first time posting cause it's my first time setting up mediawiki on my server. I'm using nginx and I installed mediawiki under /var/www/html/w/. I setup short urls and it's working but it's routing all my traffic that goes to edhel.online to edhel.online/wiki/Main_Page.
The first thing I would like to do is have my main website, preferably I'll setup a wordpress at edhel.online and have the mediawiki at edhel.online/w/ or at wiki.edhel.online. Is there a way to do this while maintaining short urls or does the wiki need to be my landing page?
I originally had it installed in a mediawiki/ folder instead of w/ but I couldn't get wiki.edhel.online to work.
Mediawiki: 1.34.0
PHP: 7.4
Databse: MySql/MariaDB
/etc/nginx/sites-availale/default:
server {
listen 80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html index.php;
server_name wiki.edhel.online;
# return 301 https://$host$request_uri;
# location / {
# try_files $uri $uri/ =404;
# }
# location ~ \.php$ {
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
# include snippets/fastcgi-php.conf;
# }
}
server {
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name wiki.edhel.online; # managed by Certbot
# Location for wiki's entry points
location ~ ^/w/(index|load|api|thumb|opensearch_desc)\.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # or whatever port your PHP-FPM list$
}
# Images
location /w/images {
# Separate location for images/ so .php execution won't apply
}
location /w/images/deleted {
# Deny access to deleted images folder
deny all;
}
# MediaWiki assets (usually images)
location ~ ^/w/resources/(assets|lib|src) {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
# Assets, scripts and styles from skins and extensions
location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg|wasm)$ {
try_files $uri 404;
add_header Cache-Control "public";
expires 7d;
}
# Favicon
location = /favicon.ico {
alias /w/images/6/64/Favicon.ico;
add_header Cache-Control "public";
expires 7d;
}
## Uncomment the following code if you wish to use the installer/updater
## installer/updater
#location /w/mw-config/ {
# # Do this inside of a location so it can be negated
# location ~ \.php$ {
# include /etc/nginx/fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root/w/mw-config/$fastcgi_script$
# fastcgi_pass unix:/run/php/php7.4-fpm.sock; # or whatever port your PHP-$
# }
#}
# Handling for the article path (pretty URLs)
location /wiki/ {
rewrite ^/wiki/(?<pagename>.*)$ /w/index.php;
}
# Allow robots.txt in case you have one
location = /robots.txt {
}
# Explicit access to the root website, redirect to main page (adapt as needed)
location = / {
return 301 /wiki/Main_Page;
}
# Every other entry point will be disallowed.
# Add specific rules for other entry points/images as needed above this
location / {
return 404;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/edhel.online/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/edhel.online/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.edhel.online) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = edhel.online) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name edhel.online;
return 404; # managed by Certbot
}