【发布时间】:2013-02-27 07:28:27
【问题描述】:
好的,我完全按照codeigniter文档中的要求做了,创建了新文件.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我使用的是xampp,所以我访问该网站的网址是
http://localhost:12/projects/zorkif_nextgen/index.php/main
现在在应用上述 .htaccess 文件后,我在没有 index.php 的情况下尝试过这样的
http://localhost:12/projects/zorkif_nextgen/main
但它没有工作,而是将我重定向到这个网址
http://localhost:12/xampp
如何解决这个问题?
另外,在尝试 .htaccess 后我的页面上出现错误
出现在页面顶部的消息,
Error Occured.
Warning!. Make sure you perform the correct action.
The Action has been completed Successfully.
编辑:
这是我的一些 config.php 文件设置
$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
$config['enable_hooks'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd'; // experimental not currently in use
$config['sess_cookie_name'] = 'zk_ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'sys_ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['rewrite_short_tags'] = FALSE;
【问题讨论】:
-
在您的根文件夹/.htaccess 中使用
RewriteRule ^(.*)$ index.php/$1 [L]而不是RewriteRule ^(.*)$ /index.php/$1 [L]
标签: php .htaccess codeigniter routing