Topic on Manual talk:Short URL

Setting short URLs breaks CSS, causes most links to 404

3
129.19.129.22 (talkcontribs)

URLs on my wiki looked like this immediately after install:

[myserver]/index.php?title=Main_Page

After configuring short URLs per this article, the above URL still "works" without CSS, but all links point to URLs like this:

[myserver]/wiki/Main_Page

These are the correct URLs, but they 404. Worse still, reverting the changes to /etc/httpd/conf/httpd.conf and /var/www/mediawiki/LocalSettings.conf does not revert to the default behavior even after reloading or restarting the service or restarting the server.

How do I fix this?

129.19.129.22 (talkcontribs)

I figured it out. When using the default httpd config for RHEL, the following changes need to be made:

  • The only change to /etc/httpd/conf/httpd.conf should be to set AllowOverride All under <Directory "/var/www/mediawiki">.
  • Set the following in /var/www/mediawiki/.htaccess:
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]
  • Note that the /w was removed from the last two lines.
  • Set the following in /var/www/mediawiki/LocalSettings.php:
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
  • Note that $wgScriptPath has been set to blank.
Dylan Banta (talkcontribs)

I'm having this same issue but I'm using Nginx, does anyone know what kind of changes I need to make for Short URLs with nginx?


Edit: Resolved


server {

   # your existing server configuration

   # ...

   # Short URLs for MediaWiki

   location /wiki {

       try_files $uri $uri/ @mediawiki;

   }

   location @mediawiki {

       rewrite ^/wiki(/.*)?$ /index.php?$1 last;

   }

   location ~ \.php$ {

       # your existing PHP configuration

       # ...

       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

       include fastcgi_params;

   }

   # ...

}

Reply to "Setting short URLs breaks CSS, causes most links to 404"