Al-Amin Sarker
Al-Amin Sarker

Reputation: 508

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';
}
}

Upvotes: 3

Views: 1877

Answers (2)

Razib Al Mamun
Razib Al Mamun

Reputation: 2711

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

Upvotes: 2

Amro
Amro

Reputation: 31

If you have CodeIgniter install in your main domain add RewriteBase / in your .htaccess

Upvotes: 0

Related Questions