I have a requirement where I need to run two separate applications using codeigniter 3.11 where one is already running from root directory and other one should be run from a subdirectory on same server and domain. I have following limitations
- I can't have a subdomain
- I can't have virtual host setting where in both applications run on their own directory like example.com/site1 and example.com/site2. Because already site1 is use in public from many years and running from root like example.com will show site1. Now I can't ask users to use example.com/site1 instead of example.com.
- I can't use 2 separate application folders because main application is having many files outside application folder also. The 2nd application is only for few users and entirely independent. But it should be available under the url example.com/site2. Please guide me how to achieve it.
This is what I have done as of now.
- Created a directory entry inside apache conf that refers to site2.
- Tried to use the htaccess to make site2 working but couldn't. Tried different htaccess changes but they need a subdomain to work which I can't have.
- Currently having default htaccess file for CI 3.11.
Changes I made to
Virtualhosts
set DocumentRoot /var/www
Alias / /var/www/html
<Directory /var/www/html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
Alias /site2 /var/www/site2
<Directory /var/www/site2>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
site1 .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
.htaccess site2
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /site2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
But both sites won't work if I try like below
http://site1 -- Forbidden
http://site1/site2 -- The requested URL was not found on this server
I am expecting the site1 to show up when example.com is visited and site2 to show up when example.com/site2 is visited.
Any help is highly appreciated.
Thanks