0

I set up 2 new systems for us, a Nagios and a MediaWiki installation, both on separate virtual systems.

The nagios system on Apache works using a ScriptAlias directive and is available under

nagios.ourdomain.com/nagios3

I've tried to set up a redirect from nagios.ourdomain.com to nagios.ourdomain.com/nagios3. I found out that a redirect in the sites-available entry for the *:80 virtual host redirected endlessly. In the documentation I found that the Redirect directive takes precedence over a ScriptAlias directive. I've solved this by allowing an override for the standard www serving directory (var/www), then placing a .htaccess into it with a

Redirect 301 / /nagios3

This works like a charm.

Now, with the wiki system, I want to do a similar redirect from wiki.ourdomain.com to wiki.ourdomain.com/wiki, although the wiki already works calling the /wiki url directly. The mediawiki installation is served directly from the standard wwwroot /var/www by a symlink /var/www/wiki pointing to the mediawiki directory.

Now, as before, I changed the *:80 vhost directive, added the

<Directory /var/www>
    AllowOverride   FileInfo
</Directory>

and placed the .htaccess with the

Redirect 301 / /wiki

into var/www. However, calling wiki.ourdomain.com now redirects endlessly, always adding /wiki to the URL.

For the nagios, I understood it was a problem of directive precedence. But with the mediawiki directory directly linked into the wwwroot of the server, I do not understand how the .htaccess of /var/www can be used multiple times, if the first redirect already redirects to a subdirectory (although a symlinked one).

Is this a problem of the symlink? Am I doing the configuration wrong somehow? I will accept a solution of doing the redirect differently, although I'm interested in the problem itself.

3
  • Where does the symlink point to?
    – Jenny D
    Dec 12, 2013 at 9:22
  • 1
    And out of curiousity, why not just set up a virtualhost entry that has the root directory pointing to the directory where the application lives to start with, instead of having a redirect?
    – Jenny D
    Dec 12, 2013 at 9:22
  • The symlink points to /var/lib/mediawiki, which is the installation directory for mediawiki using the Debian Package Management System. The reason the symlink shenanigans exist is that it's the way Debian installs it, knowing that the apache default config uses /var/www as the *:80 wwwroot.
    – Dabu
    Dec 12, 2013 at 9:25

1 Answer 1

0

I'm guessing that what happens is that Apache can't read the symlinked directory (/var/lib/mediawiki), andwhen it's trying to locate the error page it gets caught by your redirect.

When you're using a symlink to point to a directory that's not already in the apache directory tree, you need to add a directive for the target directory. A symlink basically means "hey, look over in that place over there instead" - so you need to allow apache to actually do that in order to serve the content.

But, if it were my server, I'd simply change the vhost configuration to point to the right directory from the start instead, like this:

<VirtualHost *:80>
    ServerName wiki.example.com
    DocumentRoot /var/lib/mediawiki
</VirtualHost>

It's quite normal to serve content from a separate directory from where the actual Apache installation lives; using redirects and symlinks will just complicate matters.

5
  • The directory is in the apache directory tree. I found the whole configuration for /var/lib/mediawiki under /etc/apache2/conf-available. Adding the code you supplied to the /etc/apache2/sites-available/000-default yields access problems, so this opens another can of worms.
    – Dabu
    Dec 12, 2013 at 10:46
  • /var/lib/mediawiki is not under /var/www. One of us must have misunderstood something.
    – Jenny D
    Dec 12, 2013 at 11:49
  • The only vhost is *:80, and for that the root is /var/www. There's a separate configuration for the mediawiki directories under /etc/apache2/conf-available, which configures settings for /var/lib/mediawiki/, /var/lib/mediawiki/config, /var/lib/mediawiki/images and /var/lib/mediawiki/upload. The way a request lands in these directories is by the symlink in /var/www called wiki, which references to /var/lib/mediawiki.
    – Dabu
    Dec 12, 2013 at 12:09
  • I understand this. Did you understand the part where a symlink does not mean that the target of the link is considered a part of the directory where the link resides?
    – Jenny D
    Dec 12, 2013 at 13:18
  • Well, Apache can most definitely read the symlinked directory, as the wiki works quite well when called directly as wiki.ourdomain.com/wiki.
    – Dabu
    Dec 12, 2013 at 13:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .