Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subdomain does not work for CodeIgniter

I've a Subdomain under a maindomain. I want to install CodeIgniter under subdomain. But subdomain does not work for CodeIgniter default route.

Like my subdomain is demo.example.com not working. Normally core php is working for this subdomain but CodeIgniter not.

But when I call demo.example.com/welcome then working. Here welcome is a Controller name.

Can anyone help me what is my wrong ?

My Base URL is:

$config['base_url'] = 'http://demo.example.com';

My .htaccess is

RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

My default controller(welcome.php) is

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
echo 'Welcome Subdomain';
}
}
like image 914
Al-Amin Sarker Avatar asked Feb 21 '26 16:02

Al-Amin Sarker


1 Answers

Your controller name is Welcome.php as a public_html/demo/application/controllers/Welcome.php.

Please change instead Welcome.php to welcome.php

Set instead $route['default_controller'] = "Welcome" to $route['default_controller'] = "welcome" in routes.php

like image 130
Razib Al Mamun Avatar answered Feb 23 '26 07:02

Razib Al Mamun