【发布时间】:2014-01-20 11:55:42
【问题描述】:
我试图从我的项目中删除 index.php 段,但我不能。我测试了 StackOverflow 中引用的几篇文章,但仍然无法。
这是我的项目结构:
(In /var/www/project directory)
project
--assets
--system
--.htaccess
--index.php
--info.php
--quickmenu.php
PHP version: 5.3.10
SO: Ubuntu 12.04
Apache version: 2.2.22
CodeIgniter: 2.1.3
我的 config.php 文件:
$config['base_url'] = "HTTP://".$_SERVER['HTTP_HOST']."/project/";
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
$config['url_suffix'] = "";
$config['language'] = "portugues";
$config['charset'] = "iso-8859-1";
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['directory_trigger'] = 'd'; // experimental not currently in use
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['log_threshold'] = '1';
$config['log_path'] = '';
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['cache_path'] = '/var/ci/cache/';
$config['encryption_key'] = "q7uP3mprMYuFFvbNcXyC6uPXs2ZUezxh";
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_storage'] = 'database';
$config['sess_database'] = 'default';
$config['sess_timeout'] = 7200;
$config['sess_destroy_on_timeout'] = FALSE;
$config['sess_update_interval'] = 180;
$config['sess_gc_probability'] = 10;
$config['sess_http_only'] = FALSE;
$config['sess_secure'] = FALSE;
$config['sess_forwarded_ip'] = FALSE;
$config['cookie_prefix'] = "";
$config['cookie_domain'] = "";
$config['cookie_path'] = "/";
$config['global_xss_filtering'] = FALSE;
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
/* End of file config.php */
/* Location: ./system/application/config/config.php */
我的 .htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/
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>
补充:
使用网址不起作用:
http://localhost/project/#../directory/controller/method
使用这些网址可以:
http://localhost/project/#index.php/directory/controller/method
http://localhost/project/index.php/#directory/controller/method
【问题讨论】:
标签: php apache .htaccess codeigniter