22
votes

I have Joomla installed on a webserver running Ubuntu Server 12.04. The Joomla folder is located at /var/www/cms/.

My vhost file at /etc/apache2/sites-enabled/default has the following content:

<VirtualHost *:80>
    ServerName domain.com/
    Redirect permanent / https://domain.com/
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName domain.com:443

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

    (...)
</VirtualHost> 

At the moment, all the requests to domain.com and anything entered after that like domain.com/example gets directed and processed by Joomla which either redirects to a proper page or returns a custom 404 error. This all works.

Now, I would like to filter all the requests that go to domain.com/subfolder before they get processed by Joomla and redirect them to /var/www/subfolder (instead of my root folder at /var/www/cms/).

I believe the file in /etc/apache2/sites-enabled/default (seen above) is the right place to define such a redirect, however I have not been able to figure out at what position and how to achieve this.

1
Have you tried using an alias?MasterAM
@MasterAM That's what I missing. Thanks! Alias /subfolder /var/www/subfolder <Directory /var/www/subfolder> Options +Indexes AllowOverride All </Directory> Solved the problem!ojs
Try adding the following to .htaccess in the parent directory above the directory of interest: RedirectMatch ^/foo/$ /foo/bar/ or RedirectMatch ^/foo/$ /bar/baz/. Also see How to get apache2 to redirect to a subdirectory.jww

1 Answers

36
votes

You should add to your configuration:

Alias /subfolder /var/www/subfolder
<Directory /var/www/subfolder>
    Order allow,deny
    allow from all
</Directory>

and fit the configuration between "Directory" to your needs.

See the Apache documentation to have more informations.