Topic on Manual talk:Short URL/Apache

Missing information on some setups

2
Rdrg109 (talkcontribs)

I'm currently running MediaWiki in my personal computer for experimentation purposes (i.e. not planning to use it in production). I'm using Apache in Arch Linux and was able to get the short URL working.

I spent more than 4 hours trying out the solutions mentioned in this documentation. Namely, I created the file .htaccess in multiple locations, edited the options AllowOverride and Options as specified in this page, but none of these ways worked. I decided to give up on Apache and use nginx instead, since there's also documentation on how to get the Short URL for nginx.

However, I then found Short URL/Page title -- Windows & Apache without 403 on Special Pages and was able to find the solution that worked for me. My solution was to add the Rewrite rules under <Directory "/srv/http"> in the file /etc/httpd/conf/httpd.conf. As a complete beginner user of Apache, I'd like to know whether this is recommended or not so that I can add it in this manual since it is not mentioned.

I'll describe what worked for me with the hope that other users find a solution faster than me and don't have to spend as much hours as I spent doing trial and error.

1. First, I wanted my links not to have mediawiki in the URL. That is, the default configuration that is bundled in Arch Linux makes the URL of the articles have the following format.

http://localhost/mediawiki/index.php/Main_Page

but I wanted the pages to exist in

http://localhost/w/index.php/Main_Page

To do this, I changed the first line of /etc/webapps/mediawiki/httpd-mediawiki.conf from Alias /mediawiki "/usr/share/webapps/mediawiki" to Alias /w "/usr/share/webapps/mediawiki"

2. Uncomment the line #LoadModule rewrite_module modules/mod_rewrite.so in the file /etc/httpd/conf/httpd.conf

3. Add the RewriteEngine and RewriteRule instructions under the section <Directory "/srv/http"> in the file /etc/httpd/conf/httpd.conf (see code block below)

(omitted lines)

DocumentRoot "/srv/http"
<Directory "/srv/http">
    RewriteEngine On
    RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

(omitted lines)

4. I then opened /usr/share/webapps/mediawiki/LocalSettings.php to make sure that the variables had the following values. By default, the variable $wgScriptPath already had that value, I just needed to add the line for $wgArticlePath below it.

$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";

5. Finally, I restarted the service.

$ systemctl restart httpd.service

At this point, I was able to visit the Main Page using the following URLs.

http://localhost/w/index.php/Main_Page
http://localhost/wiki/Main_Page
Ciencia Al Poder (talkcontribs)
Reply to "Missing information on some setups"