# Vhosts, /etc/hosts, MediaWiki and relative URLs

## Match

I just recently upgraded Apache and took the opportunity of having just httpd.conf to learn its syntax more in detail. I got as far as adding a new virtual host for my localhost wiki (running Mediawiki 1.4). I added this to my /etc/hosts file:

```
192.168.1.4 wiki
```

This is the file wiki.conf in my vhosts.d folder:

```
<VirtualHost *:80>

    ServerName wiki

    DocumentRoot /var/www/localhost/htdocs/wiki

    <Directory "/var/www/localhost/htdocs/wiki">

        Options All

        AllowOverride All

        Order allow,deny

        Allow from all

    </Directory>

</VirtualHost>
```

It works fine... except for one problem. Any internal links on the main part of the wiki page (the bit that changes depending on which page you're on) are broken. For example, if my wiki were the Gentoo Wiki main page, the links on the left (Wiki News, Recent Changes etc.) and at the top (Article, Discussion and Bugs etc.) would be fine; the links on the main page (Gentoo-Portage, Sandbox etc.) are broken. They all point to things such as http://index.php/?title=Main_Page&action=edit&section=1 or http://index.php/?title=Foo_bar - in the source they come out as //index.php?title=Main_Page&amp;action=edit&amp;section=1 or //index.php/?title=Foo_bar. (Edit: I just tried typing in the URL of another page manually and discovered that everywhere I go apart from the main page, the links work perfectly... it's only on the main page there are problems, and only then in the main content section...)

My LocalSettings.php file contains the lines:

```
$wgServer = "http://wiki";

$wgScriptPath = "";

$wgScript = "/index.php";

$wgRedirectScript = "/redirect.php";

$wgArticlePath      = "$wgScript?title=$1";
```

Does anyone have any idea what the problem could be? It seems to be something to do with the vhost as it worked fine at http://localhost/wiki/ (though the mod_rewrite rule to get nice article URLs has broken during the upgrade).

I'm hoping that either it's a problem not just for MediaWiki, or there's some MediaWiki savvy soul out there. If that's you, your help would be greatly appreciated. If it's not, I hope the problem is more generic...

----------

## Match

Hmm.

I started up the computer just now, and it worked. Everything's working fine. It's great. Really confusing though...

Please close this thread if you can and you notice it  :Smile: 

----------

## Phk

(Delete the first one, and they will all disappear!)

Phk

----------

## Match

Unfortunately it appears I can't delete this post now that you've replied...  :Cool: 

----------

## Phk

lolllllllllllllllll.....

my fault then....  :Very Happy: 

See us!

----------

## odioworks_com

since this is kinda on the same topic - does anyone know if it is possible to run two wikimedia sites on the same server?

I already have vhosts set up and working... 

I figured it should be possible but I obviously can't emerge mediawiki twice.  Can't find anything related to this topic on http://wikipedia.sourceforge.net/ although it seems the wikimedia servers are down.

any ideas?

----------

## Match

The answer is, it must be possible as I can install a Mediawiki on my virtual hosting package. As to how you'd go about it, you'd copy the Mediawiki files that were created in the emerge into another directory. I personally just downloaded the source of Sourceforge and didn't emerge (possibly because I didn't realise it'd have an ebuild, but never mind).

Then you'd duplicate any .htaccess files or Alias entries in httpd.conf/one of your vhosts to get the URLs working, if you wanted that.

----------

## Herring42

You need to rerun the webappconfig, giving the new virtual host name as a parameter.

Then when you run the install, make sure you pass different prefixes for the MySQL parts.

----------

