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 8201201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:43:39+00:00 2026-06-07T06:43:39+00:00

CodeIgniter by default support only one application. I want multiple applications based on subdomain.

  • 0

CodeIgniter by default support only one application. I want multiple applications based on subdomain. So subdomain is the application folder name. If existed it should execute that else default. Here my requirement and logic goes…

Requirement:

http://dynamic.com              applications/application (default)
http://appone.dynamic.com       applicatons/appone
http://apptwo.dynamic.com       applicatons/apptwo
....                            ....
http://appx.dynamic.com         applicatons/appx

when visitor type example URL like above, .htaccess or index.php should auto select which application folder to use.

I change codeIgniter default code in index.php and write this code which is working fine.

// multiple applications path //
$path = 'applications/';
// default folder //
$folder = 'application';

preg_match('/^(?<subdomain>\w+)\.(dynamic\.com)$/im', $_SERVER['HTTP_HOST'], $matches);
if (isset($matches['subdomain']) && is_dir($path . $matches['subdomain'])) {
    $folder = strtolower($matches['subdomain']);
}
$application_folder = $path . $folder;

My question – Is it possible to write same logic in .htaccess? Is there any performance issue writing the code like mine in index.php? Suggest me or Help me on htaccess logic. Image also attached. Thank you!!

enter image description here

  • 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-07T06:43:40+00:00Added an answer on June 7, 2026 at 6:43 am

    The way you’re doing it is correct. You’re setting the application folder that CodeIgniter will use in the index.php file.

    Your only concern with performance would be your preg_match function and is_dir function. In my opinion, the string is rather small which shouldn’t be too much of a performance risk. I would however, write in a switch() statement so that they are more hard-coded so that you can avoid the is_dir function. By doing this method, you’d also switch to using if statements, which are extremely cheap instead of the preg_match function.

    There’s not reason to write this in the .htaccess file, CodeIgniter gives you the ability to perform this. If you were to use this using .htaccess, you would need to have separate folders for install and start symlinking.

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

Sidebar

Related Questions

I am doing php in Codeigniter framework.Always Codeigniter support default persistent connections.I don't want
I am currently using CodeIgniter to support one site, whose main purpose is to
I would like to access the $db['default']['dbprefix'] variable from /application/config/database.php ( CodeIgniter configuration file)
I want to create a default layout for whole codeigniter project. (like cakephp) I
I'm working on Codeigniter + HMVC based application and I'm trying to add a
I am getting a Unable to load the requested file: default.php error in codeigniter
Codeigniter won't redirect the url oauth://application properly, pinning it after the current domain like
I'm trying to use Codeigniter OpenID library and everything work fine with default configuration
I am trying to implement a Codeigniter based app on Android via phonegap, all
I am using the default Codeigniter page cache e.g.: $this->output->cache(n); My problem is that

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.