我正在为我的一个项目使用codeigniter。我在本地解决了从URLS中删除index.php的问题,但昨天我在暂存服务器上配置了我的代码。我在我的暂存服务器上启用了apache中的resite mod。配置文件和.htaccess与我在本地机器上使用的文件相同。但是我仍然有URL中的index.php的问题
我的配置.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
我的数据库文件
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
我的.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mediabox
RewriteCond $1 !^(index'.php|css|images|js|robots'.txt)
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
我的暂存服务器的url是
http://stage.carrier.com/home/box/12
当我尝试使用上面的url打开它时,它给出了404错误
但当我尝试用这个url打开时,它会打开
http://stage.carrier.com/index.php/home/box/12
主要原因是什么?任何想法
感谢
您使用的是Microsoft IIS/7.5服务器。.htaccess
文件用于Apache Web服务器,将被ASP.NET忽略。
我相信IIS本身就很好,但它可能不是PHP应用程序的最佳解决方案,我建议您在CI/PHP项目中使用常规LAMP堆栈。