有没有办法从url中删除index.php文件

时间:2014-05-20 16:33:52

标签: php codeigniter

我想删除" index.php"来自我的htaccess文件的URL内容在

之下
 RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /qasim/outlets/index.php/$1 [L]

working URL
localhost/qasim/outlets/index.php/items_controller/

Error on
localhost/qasim/outlets/items_controller/

有没有办法摆脱index.php:)

我的config.php文件内容文件如下:

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


$config['base_url'] = '';


$config['index_page'] = '';


$config['uri_protocol'] = 'REQUEST_URI';

$config['url_suffix'] = '';


$config['language'] = 'english';


$config['charset'] = 'UTF-8';


$config['enable_hooks'] = FALSE;



$config['subclass_prefix'] = 'MY_';


$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['log_threshold'] = 0;

$config['log_path'] = '';

$config['log_date_format'] = 'Y-m-d H:i:s';

$config['cache_path'] = '';


$config['encryption_key'] = 'abc';


$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;


$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

$config['global_xss_filtering'] = FALSE;


$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;


$config['compress_output'] = FALSE;


$config['time_reference'] = 'local';


/
$config['rewrite_short_tags'] = FALSE;


$config['proxy_ips'] = '';

在完成所有更改后,我的配置文件现在看起来像它但不起作用

1 个答案:

答案 0 :(得分:1)

在config.php中添加以下内容替换

$config['index_page'] = "index.php"     至     $config['index_page'] = ""

替换    $config['uri_protocol'] ="AUTO"的{​​{1}}

在.htaccess

$config['uri_protocol'] = "REQUEST_URI"

编辑XAMPP中域名下的托管网站

编辑RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA]` (将该文件拖放到记事本) 在文件末尾添加此行 C:\Windows\System32\drivers\etc\hosts

修改127.0.0.1 www.test.com

在最后添加这些代码

Fullpath\XAMPP\apache\conf\extra\httpd-vhosts.conf

确保使用您的确切路径替换Fullpath。重启apache重新启动浏览器并输入www.test.com

你可以看到你的项目&amp;然后检查重写。