Use pretty URLs

This commit is contained in:
2025-08-21 19:40:05 +00:00
parent 39a234bcbc
commit a3e03c2bef

View File

@ -119,6 +119,9 @@ echo "[*] Applying additional configuration..."
cat >> "$LSETTINGS" <<EOF
# Enable Pretty URLs
\$wgArticlePath = "/wiki/$1";
# Enable file uploads
\$wgEnableUploads = true;
@ -193,7 +196,7 @@ server {
listen [::]:443 ssl default_server;
server_name _;
root $MW_DIR;
root /var/www/html;
index index.php;
ssl_certificate /etc/ssl/mediawiki/selfsigned.crt;
@ -201,41 +204,51 @@ server {
add_header X-Content-Type-Options nosniff;
location = /activate {
return 301 /activate/;
# Redirect root to Main_Page (pretty URL)
location = / {
return 302 /wiki/Main_Page;
}
location / {
try_files \$uri \$uri/ @rewrite;
# Pretty URL support: /wiki/Title
location /wiki/ {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?title=\$1&\$args;
rewrite ^/wiki/(.*)$ /index.php?title=$1&$args;
}
# Block direct access to maintenance scripts
location ^~ /maintenance/ {
return 403;
}
location ~ \.php\$ {
# Handle PHP files
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Static content caching
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|ttf|woff|woff2)$ {
try_files \$uri /index.php;
try_files $uri /index.php;
expires max;
log_not_found off;
}
# Redirect /activate to /activate/
location = /activate {
return 301 /activate/;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://\$host\$request_uri;
return 301 https://$host$request_uri;
}
EOF