24

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.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
ojs
  • 243
  • 1
  • 2
  • 4
  • Have you tried using an alias? – MasterAM Sep 27 '13 at 16:12
  • @MasterAM That's what I missing. Thanks! Alias /subfolder /var/www/subfolder Options +Indexes AllowOverride All Solved the problem! – ojs Sep 27 '13 at 16:27
  • 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](http://serverfault.com/q/9992/145545). – jww Nov 06 '16 at 08:21

1 Answers1

38

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.

Vincenzo Petrucci
  • 843
  • 1
  • 8
  • 15