codeIgniter |从的.htaccess删除网址的index.php网址、htaccess、codeIgniter、index

2023-09-02 00:34:23 作者:花醉伊人泪

OK,我没有完全按照要求的codeigniter的文档中,创建新文件的.htaccess

  RewriteEngine叙述上
的RewriteCond $ l ^(指数 .PHP |图片|机器人 .TXT)!
重写规则^(。*)$ /index.php/$1 [L]
 

我使用的XAMPP,所以我的网址来访问网站

 的http://本地主机:12 /项目/ zorkif_nextgen / index.php文件/主
 

现在应用上述.htaccess文件后,我想它的index.php没有像这样

 的http://本地主机:12 /项目/ zorkif_nextgen /主
 
仙女闻闻 从武大到伯克利到亚马逊的小透明成长史

但不是工作,这是我重定向到这个网址

 的http://本地主机:12 / XAMPP
 

如何解决这个问题?

再加上我想在以后的.htaccess我的网页上得到错误

页消息的顶部出现,

 出错。
警告!。请确保您执行正确的操作。
该行动已成功完成。
 

编辑:

下面是我的一些config.php文件设置

  $配置['BASE_URL'] ='';
$配置['index_page'] ='的index.php';
$配置['uri_protocol'] ='自动';
$配置['url_suffix才能'] ='';
$配置['enable_hooks'] = FALSE;
$配置['permitted_uri_chars'] ='AZ 0-9〜%:_   - 。;
$配置['allow_get_array'] = TRUE;
$配置['enable_query_strings'] = FALSE;
$配置['controller_trigger'] ='C';
$配置['function_trigger'] ='M';
$配置['directory_trigger'] ='D'; //实验当前未使用
$配置['sess_cookie_name'] ='zk_ci_session';
$配置['sess_expiration'] = 7200;
$配置['sess_expire_on_close'] = TRUE;
$配置['sess_encrypt_cookie'] = TRUE;
$配置['sess_use_database'] = TRUE;
$配置['sess_table_name'] ='sys_ci_sessions';
$配置['sess_match_ip'] = FALSE;
$配置['sess_match_useragent'] = TRUE;
$配置['sess_time_to_update'] = 300;
$配置['csrf_protection'] = TRUE;
$配置['csrf_token_name'] ='csrf_test_name';
$配置['csrf_cookie_name'] ='csrf_cookie_name';
$配置['csrf_expire'] = 7200;
$配置['rewrite_short_tags'] = FALSE;
 

解决方案

尝试定义的RewriteBase到/项目/ zorkif_nextgen

 的RewriteBase /项目/ zorkif_nextgen
 

ok, i did exactly as asked in the documentation of codeigniter, created new file .htaccess

RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

i am using xampp, so my url for accessing the site was

http://localhost:12/projects/zorkif_nextgen/index.php/main

now after applying the above .htaccess file, i tried it without index.php like this

http://localhost:12/projects/zorkif_nextgen/main

but instead of working, it is redirecting me to this url

http://localhost:12/xampp

How to resolve this issue?

plus i am getting error on my page after trying the .htaccess

on top of page message is appearing,

 Error Occured.
Warning!. Make sure you perform the correct action.
The Action has been completed Successfully. 

Edit:

Here is some of my config.php file settings

$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;

解决方案

Try defining the RewriteBase to /projects/zorkif_nextgen

RewriteBase /projects/zorkif_nextgen