Siz*_*ode 7 php .htaccess routing codeigniter
好吧,我完全按照codeigniter文档中的要求,创建了新文件.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
我正在使用xampp,所以我访问该网站的网址是
http://localhost:12/projects/zorkif_nextgen/index.php/main
Run Code Online (Sandbox Code Playgroud)
现在应用上面的.htaccess文件后,我尝试了没有像这样的index.php
http://localhost:12/projects/zorkif_nextgen/main
Run Code Online (Sandbox Code Playgroud)
但它没有工作,而是将我重定向到这个网址
http://localhost:12/xampp
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
加上我在尝试.htaccess后在我的页面上收到错误
在页面顶部的消息出现,
Error Occured.
Warning!. Make sure you perform the correct action.
The Action has been completed Successfully.
Run Code Online (Sandbox Code Playgroud)
编辑:
这是我的一些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;
Run Code Online (Sandbox Code Playgroud)
Moh*_*agy 15
这对我很有用:
1-在根文件夹中创建.htaccess文件,其中包含以下内容
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
2-从配置文件更改$config['index_page'] = 'index.php';为$config['index_page'] = '';
小智 7
尝试将RewriteBase定义为/ projects/zorkif_nextgen
RewriteBase /projects/zorkif_nextgen
Run Code Online (Sandbox Code Playgroud)