You are here: apache » apache change documentroot for a specific url
Apache change DocumentRoot for a specific URL
- Written By
- PHPin24
- Submitted At
- 2010-03-20 14:40:27
- Num Views
- 940
- Category
- Apache
|
Say I wanted to just change the documentroot just for a specific URL in apache. In this case I have two different cake installations and the one links to the other, but the domain needs to be the same on both: So I want to change the DocumentRoot for http://www.phpin24.co.za/enquire-now/ and http://www.phpin24.co.za/enquire-now/thankyou/ to a different DocumentRoot to what http://www.phpin24.co.za sits on: So the first parameter in AliasMatch is the relative URL which I want to change the DocumentRoot for and the second parameter is the path on the server I want it change the DocumentRoot to. AliasMatch relativeurl pathonserver You can add the following in your VirtualHost config replacing /var/www/html/other-site/app/webroot/ with the DocumentRoot of your other site: AliasMatch ^/enquire-now/thankyou/(.*) /var/www/html/other-site/app/webroot/$1 AliasMatch ^/enquire-now/(.*) /var/www/html/other-site/app/webroot/$1 Notice that the /enquire-now/thankyou/ match is before the normal /enquire-now/ match. This is because the /enquire-now/thankyou/ match will only execute last as it is the thankyou page, because the /enquire-now/ would match on /enquire-now/thankyou/ as well, I put the thankyou match first. So that it does not only run the enquire-now and not the thankyou match. Here's the full example... <VirtualHost *:80> ServerName www.phpin24.co.za DocumentRoot /var/www/html/phpin24 AliasMatch ^/enquire-now/thankyou/(.*) /var/www/html/other-code/app/webroot/$1 AliasMatch ^/enquire-now/(.*) /var/www/html/other-code/app/webroot/$1 ErrorLog /var/log/httpd/phpin24/phpin24_error_log CustomLog /var/log/httpd/phpin24/phpin24_access_log combined <Directory /var/www/html/phpin24/> Options FollowSymlinks AllowOverride All FileETag none </Directory> </VirtualHost> By PHPin24 @ 2010-03-20 14:40:27
|
