I am trying to configure virtual hosts with multiple sites with codeigniter based on folders on ubuntu 18 with Apache2. By this what I mean is site1 is to be accessed by using url http://localhost/site1 and site2 is to be accessed by using url http://localhost/site2 and site3 is to be accessed by using url http://localhost/site3 and so on. Content to be served are in folders under /var/www/site1 and /var/www/site2 etc. I can't use name based virtual hosts because the users will be using it over the network not in the local machine.
So I updated default config file on ubuntu like below
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Alias /site1 /var/www/site1/html
<Directory /var/www/site1/html>
Options +MultiViews -Indexes +Includes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias /site2 /var/www/site2/html
<Directory /var/www/site2/html>
Options +MultiViews -Indexes +Includes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias /site3 /var/www/site3/html
<Directory /var/www/site3/html>
Options +MultiViews -Indexes +Includes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Folder structure is like below /var/www/site1/html /var/www/site2/html /var/www/site3/html etc.
I am able to access site1 normally without any issue. But for site2 and site3 I am getting 500 internal server error with message " Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. " in the logs. When enabled debug mode following messages were in the log.
: r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895466 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895478 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895490 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895501 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895512 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895523 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895534 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895562 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895573 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/html/index.php/master/get_announcements, referer: http://192.186.1.4/site2/
[Mon Feb 01 12:07:57.895583 2021] [core:debug] [pid 8335] core.c(3840): [client 192.186.1.3:57079] AH00122: redirected from r->uri = /site2/master/get_announcements, referer: http://192.186.1.4/site2/
If it helps following is the .htaccess in the /var/www/site2 folder
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
This same .htaccess is present in all the three directories. But it works only for first one for other 2 it gives error as mentioned above.
Please help me fix this.
Thanks a lot in advance