Topic on Manual talk:Short URL/Apache

Cann't get this extension working

5
Summary by Berot3

probably not relevant anymore

Solanki (talkcontribs)

Hi,

I am not able to get this extension working. All my efforts either ends up in 400 not found or Bad Request.

what I am doing is, added following in my LocalSettings.php

require_once("$IP/extensions/ShortLinks/ShortLinks.php");
$wgArticlePath = "wiki/$1";
$wgUsePathInfo = false;


Added following in httpd.conf file:

LoadModule rewrite_module modules/mod_rewrite.so

<syntaxhighlight lang="php" strict>
<VirtualHost IP:port no>
RewriteEngine On
DocumentRoot "/path/to/apache/webroot/"

<Directory /path/to/apache/webroot/>
AllowOverride All
Require all granted
</Directory>

RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/Mediawiki-1.23/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
	
</VirtualHost>

Value for following variables are:

$wgArticlePath = "/wiki/$1";
$wgScriptPath = "/Mediawiki-1.23";

What I am expecting is, that in the browser I should get the URL as "http://IP/Mediawiki-1.23/ " (w/o the index.php) and also it should be able to navigate within the wiki w/o having the index.php in the URL. I am trying this on Apache 2.4 and PHP 5.4. Please suggest, how can I get this working?

Dantman (talkcontribs)

$wgArticlePath = "wiki/$1"; is wrong, it must start with /.

Besides that it doesn't look like you have followed the guide at all.

The -f and -d don't apply when doing /wiki/$1 urls and mediawiki is in a separate folder and they're in the wrong spot.

And there is no mention anywhere of RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L], which is likely intercepting any url belonging to your wiki and sending it somewhere else.

Solanki (talkcontribs)

Actually, when I wasn't able to make it work, I took reference from many sources and clubbed too many parameters in the hope that it would work. Apparently, now it works, Thanks to you. The only thing I am wondering now, is how to get it working for every links within the wiki like the way it is working for main page.

Dantman (talkcontribs)

If it doesn't work outside the main page, are you sure $wgArticlePath is set right?

Solanki (talkcontribs)

I have set: $wgArticlePath = "/wiki/$1"; What I am trying to say is, if u crate a new page, then the URL for that page must behave in the same manner, but here it isn't. So, Is there any thing else I need to take care of?