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