Skip to content
Snippets Groups Projects
Commit dcc9dae9 authored by Jelle van der Waa's avatar Jelle van der Waa :construction:
Browse files

Merge branch 'wiki-short-url' into 'master'

archwiki: Implement short URLs

See merge request !335
parents 00d1e776 b8407cdc
No related branches found
No related tags found
1 merge request!335archwiki: Implement short URLs
Pipeline #6875 passed
......@@ -61,3 +61,13 @@ $wgMemCachedServers = [ "unix://{{ archwiki_memcached_socket }}:0" ];
# security headers
$wgReferrerPolicy = ["no-referrer-when-downgrade"];
$wgEditPageFrameOptions = "DENY";
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
$wgArticlePath = "/title/$1";
# $wgUsePathInfo is not necessary: https://github.com/wikimedia/mediawiki/blob/bb92c4d1acc029eed0f6848360dff5b2436695fc/includes/WebRequest.php#L151-L153
#$wgUsePathInfo = true;
......@@ -52,20 +52,19 @@ server {
deny all;
}
# special case due to our '/index.php/Main_Page' type URLs
location ~ ^/(?:index|redirect)\.php(?:/.*)$ {
access_log /var/log/nginx/{{ archwiki_domain }}/access.log main;
access_log /var/log/nginx/{{ archwiki_domain }}/access.log.json json_main;
fastcgi_pass archwiki;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
include fastcgi_params;
# Redirect old URLs to the new short-url (/title/<page>)
location ~ ^/index.php/(.*)$ {
return 307 /title/$1;
}
# Handling for the article path (pretty URLs)
location ^~ /title/ {
rewrite ^ /index.php;
}
# Handling for MediaWiki REST API, see https://www.mediawiki.org/wiki/API:REST_API
location ^~ /rest.php/ {
rewrite ^ /rest.php;
}
# special case for '/load.php' type URLs to cache css/js in nginx to relieve php-fpm
......@@ -74,11 +73,7 @@ server {
access_log /var/log/nginx/{{ archwiki_domain }}/access.log.json json_main;
fastcgi_pass archwiki;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
include fastcgi_params;
include fastcgi.conf;
fastcgi_cache wiki;
fastcgi_cache_valid 200 10m;
......@@ -88,16 +83,12 @@ server {
# normal PHP FastCGI handler
location ~ ^/[^/]+\.php$ {
try_files $uri =404;
access_log /var/log/nginx/{{ archwiki_domain }}/access.log main;
access_log /var/log/nginx/{{ archwiki_domain }}/access.log.json json_main;
fastcgi_pass archwiki;
fastcgi_index index.php;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi_params;
include fastcgi.conf;
}
# whitelist known OK directories
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment