0

I'm not a stranger to server configuration but on my local development systems (all of them), some update seems to have broken the Web sites' aliases as none work now. I'm not sure when it happened as I haven't done much development lately but when I tried, I discovered it was broken so I hope someone can help me get it going again.

This particular system is running Kubuntu but it is also broken on my two Ubuntu Studio systems, all of which are running 22.10 and Apache 2.4.54.

The conf file has this, which in this case was created by Webmin but is much the same as the existing sites that I created manually and I also tried it in the alias.conf file but it made no difference:

<VirtualHost localhost:80>
    DocumentRoot /var/www/html/domain.loc
    ServerName domain.loc
    <Directory "/var/www/html/domain.loc">
        Options None
        Require all granted
    </Directory>
    Alias /common /var/www/html/domain.loc/common
</VirtualHost>

I also tried a slight rearrangement with the Alias farther up and with the paths quoted:

<VirtualHost localhost:80>
    DocumentRoot "/var/www/html/domain.loc"
    ServerName domain.loc
    Alias "/common" "/var/www/html/domain.loc/common"
    <Directory "/var/www/html/domain.loc">
        Options None
        Require all granted
    </Directory>
</VirtualHost>

. . . and I tried it using Location tags:

<VirtualHost localhost:80>
    DocumentRoot "/var/www/html/domain.loc"
    ServerName domain.loc
    <Location "/common">
        Alias "/var/www/html/domain.loc/common"
    </Location>
    <Directory "/var/www/html/domain.loc">
        Options None
        Require all granted
    </Directory>
</VirtualHost>

As a test, I wrote a PHP script which is what I use on my live server for creating aliases and it shows me that the alias already exists so Apache is recognizing it. When it was working, if I went to a URL that included the alias, it would load just as if it were a local file:

http://domain.loc/common/index.php

Now it gives a 404 Page not found and the Apache error log shows nothing.

<?php 

$target = "/var/www/html/common";
$link = "/var/www/html/domain.loc/common";

$error = symlink($target, $link);

if ($error === TRUE) :
    echo readlink($link) . " has been linked";
else :
    echo "<p>The link already exists between $link and $target";
endif;

?>

/common and /domain.loc are, of course, on the same level as indicated in the test script above and mod_alias is installed with a2query -m alias returning alias (enabled by maintainer script)

Any ideas?

Greg Askew
  • 35,880
  • 5
  • 54
  • 82
DonP
  • 101
  • 2

1 Answers1

1

The Alias directive provides for mapping different parts of the host filesystem in the document tree.

The following:

ServerName domain.loc
DocumentRoot /var/www/html/domain.loc

is already sufficient to ensure that requests for http://domain.loc/common should show content from the location /var/www/html/domain.loc/common on your file system.

You do not need any variant of Alias for /common to achieve that.
Alias /common /var/www/html/domain.loc/common is completely redundant.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • As shown in the test script that I posted, `/common` and `/domain.loc` are at the same level, ie: `/var/www/html/common` and `/var/www/html/domain.loc` so not redundant. I've tried about every possible thing posted here and on the mod_alias page of apache.org but to no avail. – DonP Mar 10 '23 at 23:15
  • I'm not sure if this is headway or not but another forum suggested creating the `common` folder as `/var/www/html/domain.loc/common` which I tried but now `the page isn’t redirecting properly`. In the address bar is: `http://sunvirgin.loc/common/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/` even though the site has no such file name. – DonP Mar 12 '23 at 22:21
  • Anybody? Since this is happening on all three of my development PCs after updating to Apache 2.4, I can't be the only one experiencing the issue! – DonP Mar 18 '23 at 17:11