子域不适用于 CodeIgniter

Subdomain does not work for CodeIgniter

我在 maindomain 下面有一个 Subdomain。我想在 subdomain 下安装 CodeIgniter。但是 subdomain 不适用于 CodeIgniter 默认 route.

就像我的 subdomain demo.example.com 不工作一样。通常 core php 为此 subdomain 工作,但 CodeIgniter 不工作。

但是当我打电话给 demo.example.com/welcome 然后工作。这里 welcome 是一个 Controller 名字。

任何人都可以帮我解决我的问题吗?

我的基地URL是:

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

我的 .htaccess 是

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

我的默认控制器(welcome.php)是

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
echo 'Welcome Subdomain';
}
}

如果您在主域中安装了 CodeIgniter,请在您的 .htaccess 中添加 RewriteBase /

您的控制器名称是 Welcome.php 作为 public_html/demo/application/controllers/Welcome.php

请将 Welcome.php 改为 welcome.php

routes.php

中将 $route['default_controller'] = "Welcome" 设置为 $route['default_controller'] = "welcome"