Jump to content

Topic on Manual talk:Short URL

Rehman (talkcontribs)

Hello. My private test wiki is located on Apache server at https://wiki.rehman.website/w/index.php (/home/var/wiki.rehman.website/w/)

I have added .htaccess in /home/var/wiki.rehman.website/.htaccess with the following (as per Manual:Short URL/Apache):

RewriteEngine On

# main rewrite rule
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

With these settings in LocalSettings.php:

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

But when browsing to https://wiki.rehman.website/ the page loads in a bad formatting (as if something is broken). And clicking on any of the links on this page generates this error:

Not Found
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

What am I doing wrong? Any help is appreciated. Many thanks!

Þjarkur (talkcontribs)

You have your script directory as your DOCUMENT_ROOT, while the documentation assumes you have your MediaWiki directory in a subdirectory named /w. You should be able to fix this by changing "/w/index.php" to "/index.php" in your .htaccess and then set $wgScriptPath = "/";

Rehman (talkcontribs)

Thanks @Þjarkur. I've updated .htaccess per above, but unfortunately the output is still the same, strangely.

For the sake of trying, I've run shorturls.redwerks.org as mentioned at Manual:Short URL/Apache#Setup. Oddly though, the settings mentioned there are different from the official Short URL guidelines.

The redwerks links suggested that I add the below code to .htaccess:

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

And the below code/amendments to LocalSettings.php:

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

$wgEnableUploads  = true;
$wgGenerateThumbnailOnParse = false;

And to increase my frustration, that too, did not work. The landing page worked, but I cannot go beyond the login link (ends in the same error above). It seems like something has changed since the Short URL was documented, or this doesn't work with private wikis, or some other compatibility issue...

Rehman (talkcontribs)

The above https://shorturls.redwerks.org/ code was with the Include 404 thumbnail handler config ticked. Without the option, it suggested adding the below code to .htaccess:

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

And the below code/amendments to LocalSettings.php:

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

This too, did not work, even with public read access enabled.

Could this issue persist because I have the word "wiki" as part of the URL (i.e. "wiki.rehman.website/etc")?

Bawolff (talkcontribs)

i'm a little confused by your description. To clarify: Which directory is the .htaccess file in? Is your last comment the current value of the .htaccess? Which directory is your web root directory?

> Could this issue persist because I have the word "wiki" as part of the URL (i.e. "wiki.rehman.website/etc")?

No, that should not matter

Rehman (talkcontribs)

Hi @Bawolff. As of my last comment, I had undid those changes. For the sake of troubleshooting, I have now restored the below settings (and made the test wiki publicly readable):

htaccess:

RewriteEngine On

# main rewrite rule
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

I had also tried removing /w.

LocalSettings.php:

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

And these are the directories:

  • MediaWiki is located at: /home/<user>/wiki.rehman.website/w/index.php
  • .htaccess is located at: /home/<user>/wiki.rehman.website/.htaccess
  • Root directory is set as wiki.rehman.website/w/

I have also tried moving the htaccess to /home/<user>/wiki.rehman.website/w/.htaccess, but nothing works. Thank you.

Bawolff (talkcontribs)

i think he confusion comes because the instructions you are following are for if your web root diectory is /home/<user>/wiki.rehman.website/ and mediawiki is installed in a subdirectory named w. If your web root is /home/<user>/wiki.rehman.website/w/ then these instructions expect mediawiki to be installed in /home/<user>/wiki.rehman.website/w/w/

Rehman (talkcontribs)

I eventually realised the same too, and hence I did also try other options (as mentioned in previous posts). They all didn't work. If you don't mind, could you help in writing the correct htaccess and LocalSettings codes for my setup please?

Ciencia Al Poder (talkcontribs)

Looking at your configuration

Your Script path is /w, but it should be /

Everything else seems correct

Rehman (talkcontribs)

Thanks for the reply @Ciencia Al Poder. Unfortunately, that too did not work. I'm going to delete the whole wiki and retry. I think there is a bug somewhere. Will update here again. Cheers.

Bawolff (talkcontribs)

In your previous comment you had:

.htaccess in /home/<user>/wiki.rehman.website/.htaccess

if your web root is /home/<user>/wiki.rehman.website/w then placing your your htaccess in /home/<user>/wiki.rehman.website/.htaccess will mean it is totally ignored. The correct place would be /home/<user>/wiki.rehman.website/w/.htaccess

Additionally, I think the rewrite rules were wrong because they had an extra /w/

(To be clear, when I say web root, I mean whatever the DocumentRoot directive in your virtual host config of your apache config file is set to.)


Anyways. Assuming DocumentRoot is /home/<user>/wiki.rehman.website/w (i.e. the directory /home/<user>/wiki.rehman.website/ corresponds with https://wiki.rehman.website/ ), and mediawiki is installed in /home/<user>/wiki.rehman.website/w, the correct config would be

in /home/<user>/wiki.rehman.website/w/.htaccess

RewriteEngine On

# main rewrite rule
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]


In /home/<user>/wiki.rehman.website/w/LocalSettings.php

$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
Rehman (talkcontribs)

Thanks for the detailed reply @Bawolff. I did also try exactly as you said, but it too did not work. From what I understand, Short URL would not work properly when installed on document root.

I just finished reinstalling fresh again, this time as follows:

  • Server DocumentRoot configured as home/<user>/wiki.rehman.website/root/
  • MediaWiki installed in the subdirectory /w (wiki.rehman.website/w/index.php)

In the above scenario, Manual:Short URL/Apache#Simple instructions works exactly as it is mentioned.

Reply to "Seems to be buggy"