2

I have configured my apache like this:

<VirtualHost *:80>
  ServerName www.th3falc0n.de
  ServerAlias th3falc0n.de *.th3falc0n.de
  DocumentRoot /var/www/html/th3falc0n

    <Directory /var/www/html/th3falc0n>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>
  ServerName www.lolhens.org
  ServerAlias lolhens.org *.lolhens.org
  DocumentRoot /var/www/html/lolhens

    <Directory /var/www/html/lolhens>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

I have a .htaccess in /var/www/html/th3falc0n which redirects th3falc0n.de to th3falc0n.de/p/home and some other stuff. However, those rules get also applied to lolhens.org, which is not the expected behaviour. What is my fault? How can I achieve that the .htaccess only applies for th3falc0n.de?

Output of apache2ctl -S

root@v36448:~# apache2ctl -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.th3falc0n.de (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost www.th3falc0n.de (/etc/apache2/sites-enabled/000-default.conf:1)
                 alias th3falc0n.de
                 wild alias *.th3falc0n.de
         port 80 namevhost www.lolhens.org (/etc/apache2/sites-enabled/000-default.conf:15)
                 alias lolhens.org
                 wild alias *.lolhens.org
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

As I got multiple suggestions to move the .htaccess contents into the site configuration: This is not an option, as the user managing lolhens.org must have no accesss to the server configuration but be able to use .htaccess and I want to keep this consistent over all possible users.

EDIT:

After finding out, that http://www.lolhens.org doesn't have the issue with .htaccess, but it will occur on http://lolhens.org I tried another config like this:

<VirtualHost *:80>
  ServerName th3falc0n.de
  ServerAlias *.th3falc0n.de
  DocumentRoot /var/www/html/th3falc0n

    <Directory /var/www/html/th3falc0n>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

<VirtualHost *:80>
  ServerName lolhens.org
  ServerAlias *.lolhens.org
  DocumentRoot /var/www/html/lolhens

    <Directory /var/www/html/lolhens>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

This however still has the same result. www.lolhens.org works as expected, lolhens.org doesn't.

4
  • 2
    If you have access to the config files you do not need a .htaccess.
    – user9517
    Mar 21, 2015 at 12:42
  • 1
    Is the NameVirtualHost directive present in the configuration? Probably apache is ignoring the second virtual host definition and this usually happens when there is no NameVirtualHost.
    – hdanniel
    Mar 21, 2015 at 12:57
  • @HD. you should give an answer for that. Mar 21, 2015 at 12:59
  • @HD. AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/sites-enabled/000-default.conf:
    – th3falc0n
    Mar 21, 2015 at 13:46

2 Answers 2

1

If any of the content from www.lolhens.org is served from /var/www/html/th3falc0n, then the .htaccess file there will be honored, even though the user asked for a different domain.

Iain is right: Since you apparently have access to the config files, the simplest solution is to remove the .htaccess file, move its directives into the VirtualHost for www.th3falc0n.de, and disable .htaccess by setting AllowOverride none. See the Apache htaccess file tutorial.

1
  • www.lolhens.org has currently no content at all. There is no content on lolhens.org that possibly could come from th3falc0n.de
    – th3falc0n
    Mar 21, 2015 at 13:49
0

I just figured out, that the fault was the cache of my local browser, which saved the redirection for lolhens.org . The second configuration now works.

You must log in to answer this question.

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