Topic on Manual talk:Short URL/Apache

This entire page is junk and needs deleting

11
81.174.250.136 (talkcontribs)

These are the worst instructions for anything I have ever encountered.

There are just seemingly random thoughts recorded in paragraphs. Files that are mentioned are:

/etc/apache2/apache2.conf

/etc/apache2/sites-available/default.conf (this actually 000-default.conf on my distribution)

.htaccess (many places)

LocalSettings.php

Which of these files should be edited?

What is needed are instructions like this:

  1. edit <filename> - add <this line> and <this line>
  2. enable mod_somemod by typing a2enmod <mod_somemod>
  3. restart apache2 by typing systemctl restart apache2

etc.

Ciencia Al Poder (talkcontribs)

What it needs is editing, not deleting. This is a wiki, so any edit that improves the content is welcome.

2001:44C8:4400:7766:E5CD:F711:321B:495C (talkcontribs)

@Ciencia Al Poder like the anonymous user above me (believe it or not that we are not the same person) I think that you take the seriously bad situation of this webpage and how serious it misleads people, too easy.

2001:44C8:4400:7766:E5CD:F711:321B:495C (talkcontribs)

@Jonathan3 indeed, I am not the anonymous who wrote the original post but I can understand where his frustration is coming from; you told me "it's all in here" but really, sadly it's not very much the case.

Jonathan3 (talkcontribs)

I bet if you think it through and stop asking questions you'll find the answer here :-)

2001:44C8:4512:B6D6:A16F:69E9:F0A3:8BD9 (talkcontribs)

@Jonathan3 I guess you meant my recent questions on the subject in "support desk";

I nicely disagree with that approach ; I when a page is SO undidactic, it kinds of take the spirit out from cooperating, for me at least. In face I already wrote a revised version of the opener of this "guide" and should publish it soon.

Polymath uk (talkcontribs)

I'm the anonymous user. I've remembered my user/pass.


For those running debian 10 (probably Ubuntu too) with root access and apache2 do all of this as root:


1. You need to ensure the rewrite module is loaded in apache2 by doing this:

Type:

a2enmod

then when prompted type

rewrite

then press <enter>


2. Next, edit /etc/apache2/sites-available/000-default.conf by typing

nano /etc/apache2/sites-available/000-default.conf

(or your favourite editor like vi instead)

Immediately before the closing </VirtualHost> tag insert three lines that read:


RewriteEngine On

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

RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]


This assumes that your mediawiki installation is in the same directory that apache2 is treating as the document root. The document root path is shown in the file you have open. If your index.php file is in that directory then this will work. This will be the case if your URLs are http://mywiki.com/index.php If your URLs look like http://mywiki.com/somefolder/index.php then you will need to modify the above lines to look like this:


RewriteEngine On

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

RewriteRule ^/*$ %{DOCUMENT_ROOT}/somefolder/index.php [L]


Save the file


3. restart apache2 by typing:


systemctl restart apache2


If it won't restart you've done something wrong which you need to troubleshoot.


4. Next edit LocalSettings.php by typing


nano /var/www/html/LocalSettings.php


(or whatever path you are using)

Look for the text $wgScriptPath (which will probably be near the top)

As above, if your installation is directly in document root, this will probably read $wgScriptPath = ""; in which case, leave it alone. If you are in a subdirectory like above, it will read something different. Leave it alone anyway.

Add this line under it:


$wgArticlePath = "/wiki/$1";


Save the file.


Done.

Jcshy (talkcontribs)

Polymath you've been a lifesaver. Following your instructions got this done in about 10 seconds. Trying to use the incoherent instructions on the article itself had got me pulling my hair out after failing to make it work for an hour.

2A02:908:2057:7C80:4012:8145:F350:A140 (talkcontribs)

I used the script on redwerks.org, running wikipedia on a low-cost shared server. I copied the Apache Config and saved it as a new .htaccess in the directory that the URL should be redirected to, and changed the rows in LocalSetting.php. All done. This was just trial and error and I am happy it worked.

83.97.188.172 (talkcontribs)

Thank you so much

the "somefolder" tip solved de problem for me

Why you do not put this in the actual article?

Polymath uk (talkcontribs)

I didn't realize I could edit the article!

Reply to "This entire page is junk and needs deleting"