Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:12:35+00:00 2026-06-14T10:12:35+00:00

I’m looking for a solution to support multiple domains on one webhosting account, which

  • 0

I’m looking for a solution to support multiple domains on one webhosting account, which has to be done with htaccess. So the idea is, you call domainx and with htaccess the server “fakes” the webroot to a subfolder corresponding with the domain name. I allready have a “solution”, but this doesn’t work perfectly.

Problems I’ve got:

  1. Redirects through PHP (with base_url() of CodeIginiter), result in; for example “http://www.domein1.nl/domein1.nl/”.
  2. It doesn’t work on my local server.

So, the htaccess I’m currently using:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} domein1.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/domein1.nl/.*$
RewriteRule ^(.*)$ /domein1.nl/$1 [L]

RewriteCond %{HTTP_HOST} domein2.nl$ [NC]
RewriteCond %{REQUEST_URI} !^/domein2.nl/.*$
RewriteRule ^(.*)$ /domein2.nl/$1 [L]

</IfModule>

The CodeIgniter PHP-code for the base_url(). The server variable “SCRIPT_NAME” adds the second domain folder, marked as problem 1. This should’nt happen if the root folder is faked correctly; but is that actually possible?

if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}

And last but not least, it is’nt working on my local server while I do redirect through my hosts file:

192.168.2.9 local.domein1.nl
192.168.2.9 local.domein2.nl

Sooo.. How do I fix these problems? Thanks in advance!

Edit: The problem with my local server is fixed.. cough “sudo a2enmod rewrite” did the trick..

Edit2: Since stormdrain started about folder structure, here is mine to clarify the multiple CI applications.

Main .htaccess location / webroot

/public_html/.htaccess

domain1:

/application/domain1/ (domain1 application path)
/application/system/ (shared system path)
/public_html/domain1/index.php (CI domain1 index)

domain2:

/application/domain2/ (domain2 application path)
/application/system/ (shared system path)
/public_html/domain2/index.php (CI domain2 index)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:12:36+00:00Added an answer on June 14, 2026 at 10:12 am

    Well, it seems impossible to do neatly through htaccess..

    O well, I “fixed” it. My fix within the CodeIgniter index.php: I replaced the declaration of the variable $application_folder with the code beneath.

    define('DOMAIN', preg_replace(
        "/^(www.|local.)?([^.]+).[^.]+$/i", "\\2",
        $_SERVER['HTTP_HOST']
    ));
    
    if ( DOMAIN == 'domain2')
        $application_folder = '../application/domain2';
    else
        $application_folder = '../application/domain1';
    

    I also made a minor change to the system “url_helper”. Added this “static_url()” function, returning the URI to the path I save images/CSS/js etc.

    if ( ! function_exists('static_url'))
    {
        function static_url()
        {
            return base_url().'static/'.DOMAIN.'/';
        }
    }
    

    Only minor thing I’ve got to figure out is how to split up things like robots.txt

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.