2021 Top 4 Best Upcoming Flagship Smartphones : which are the best mobile phones for you..?

Image
  Hi here are the top 8 best upcoming flagship smartphones of 2021 with high-end level features improved cameras stunning design and many other next-generation technologies will be applied that you will really enjoy also the price and the release date of the smartphones are discussed. Number four Asus Zenfone 8 Number three OnePlus 9 Number two Huawei P50 Number one Apple iPad Pro 12.9

Codeigniter subdomains sharing one common app

I assume that your are using
  • Windows-7
  • WAMP Apache 2.4.2 (installed in C: directory)
  • PHP 5.4.3
  • CodeIgniter 2.x  Download
Hi there, the first question raises I our mind is 
How to add a sub-domain to be reached at: subdomain.mainsite?
So, here we start to create sub-domain for localhost.


Step 1:
Edit the file located in C:\windows\system32\drivers\etc\hosts

add the following to it
127.0.0.1 subdomain.mainsite

Save File

Step 2:
Edit the httpd.conf file

Add the following to the bottom of the file

##########################
NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www\mainsite"
ServerName subdomain.mainsite
ErrorLog logs/subdomain_error.log
</VirtualHost>
###########################

Step 3:
You must make sure the subdomain directory exists inside mainsite(CodeIgniter). If not create one.
C:\wamp\www\mainsite\subdomain

Restart Apache server.

Now navigate to C:\wamp\www\mainsite\index.php add 
$region_prefix_var = explode('.', $_SERVER['HTTP_HOST']); right after 
// $assign_to_config['name_of_config_item'] = 'value of config item';

Save file.

Now navigate to C:\wamp\www\mainsite\application\config\config.php after $config['base_url'];

add

global $region_prefix_var;
switch($region_prefix_var[0]){ 
case'subdomain':
$config['image_url'] = $region_prefix_var[0].'/images';
break;

default:
$config['image_url'] = '/images';
break;
}

I set image_url variable so that we could easily access images for specific subdomain (you can set as many variables as you need). Now in view (header.php file) set image path like:

$image_url = $this->config->item('image_url');
<?php echo anchor( "/", img(array('src' => $image_url.'logo.png')) );?>

Comments

Popular posts from this blog

2021 Top 4 Best Upcoming Flagship Smartphones : which are the best mobile phones for you..?

Import UTF-8 languages from Excel to Database using PHP

Unlink file in CodeIgniter