Welcome Guest, Not a member yet? Register   Sign In
Multiple domains with one codebase - how to set htaccess file?


I have multiple domains (two at the moment, but might be more later on), and I want them all to use the same CodeIgniter codebase, but each domain will use its own database.

I have the basic concept figured out (I hope), but the only thing I'm struggling with is the htaccess file. I want it to handle the removal of index.php from the url, as well as redirect to https and www.

Below is my .htaccess file.
On localhost it works well, but on the remote servers it creates an seemingly endless chain of index.php/index.php/index.php etc.

What am I missing here?

If it matters, I'm using CI 3.1.9

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_HOST} localhost
RewriteRule ^(.*)$ http://localhost/pi/index.php/$1 [NC,R,L]

RewriteCond %{HTTP_HOST} firstdomain.com
RewriteRule ^(.*)$ https://www.firstdomain.com/index.php/$1 [NC,R,L]

RewriteCond %{HTTP_HOST} seconddomain.com
RewriteRule ^(.*)$ https://www.seconddomain.com/index.php/$1 [NC,R,L]

I did it in a slight different way.
In DirectAdmin I created different domains (lets say for now domain1.com and domain2.com).

Then when I login into FTP, I got the following structure


Then I placed the index.php in every public_html and defined some CONSTANTS with the database connection details (host, user, pwd and port).

Also all index.php points to the same application and system directory. If I update the application or system folder, every project gets the update.

Theme © iAndrew 2016 - Forum software by © MyBB