0
votes

I have 3 websites running on a cloud server, with the default Apache httpd.conf setting . I have uncommented the NameVirtualHost and configured the 3 websites from VirtualHost, after set up the DocumentRoot and ServerName for each, all worked perfectly but only the site within the default Directory is working for mod-rewrite, which I used for SEO URLs. The other 2 sites are located just one level above the /var/www/html, and are in the subfolder of /var/www/websites/site1, site2. I've tried to use RewriteBase in the .htaccess file to make this work but no success, and I have no idea where in the httpd.conf file I can make any changes to get things right. Please help, thanks.

1

1 Answers

0
votes

If I understand you correctly you wish to have 3 separate websites running on 1 Apache server and then be able to have rewrites working on all of them.

You are on the right track using VirtualHosts. You need to stick to using a separate VirtualHost for each website you intend to host.

Given a folder structure as follows

/var/www/
- /websites
-- /site1
-- /site2
-- /site3

You can then setup 3 VirtualHosts for each of your 3 sites:

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.domain1.tld
    DocumentRoot /var/www/websites/site1
</VirtualHost>

<VirtualHost *:80>
    ServerName www.domain2.tld
    DocumentRoot /var/www/websites/site2
</VirtualHost>

<VirtualHost *:80>
    ServerName www.domain2.tld
    DocumentRoot /var/www/websites/site3
</VirtualHost>

Hope this helps.