0

I have two sites which runs independently on my VPS, let's call them site1 and site2.

They are respectively located at /var/www/html/site1 and /var/www/html/site2

I don't have a domain name yet but I can acces my site using server IP, let's say its adress is 8.8.8.8

I currently have two separate apache configuration file for each site.

Both sites are configured as follow, only DocumentRoot and the second Directory block differs.

<VirtualHost *:80>
    ServerName 8.8.8.8
    DocumentRoot /var/www/html/site
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/html/site>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I can acces both my site by enabling one and disabling the other one.

At first I wanted to have a separated subdomain http://site2.8.8.8.8/* but since I don't have a DNS record yet I can't really achieve it without modifying the local hosts file on every computer which wants to acces website.

So I though a better solution could be to have site1 running on http://8.8.8.8/* and site2 running on http://8.8.8.8/site2/*

Apparently it can be done using RewriteCond but I can't find a way to make it work.

Is my aim really achievable without having DNS records ?

Otherwise couldn't that be achieved by running site2 on another port like 8080 and redirecting to this port ?

0

I finally found how to do it

I just created an apache configuration inspired from phpmyadmin one.

  • site1 is defined as a virtualhost in apache site
  • site2 is defined as an Alias in apache configuration

Here are the minimal configuration files for those interested

# cat /etc/apache2/site-enabled/site1.conf
<VirtualHost *:80>
    ServerName 8.8.8.8
    DocumentRoot /var/www/html/site1
</VirtualHost>


# cat /etc/apache2/conf-enabled/site2.conf
Alias /site2 /var/www/html/site2

<Directory /var/www/html/site2>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    AllowOverride All
</Directory>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.