2014-05-20 39 views
2

index.php文件,我想從我的htaccess文件的我的網址內容中刪除「的index.php」低於是有什麼辦法可以刪除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'] = ''; 

所有的改變,現在我的配置文件看起來像它之後,但它不工作

+0

您正在通過localhost訪問它,而不是域..這可能是一個重寫問題。請告訴我你的操作系統和網絡服務器是哪一個? – Harikrishnan

+0

我使用win7,xampp和我工作的框架是codeigniter。 –

+0

不工作是否有任何其他設置與xampp有關,因爲我第一次使用.htaccess? –

回答

1

在config.php中添加以下內容替換

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

通過$config['uri_protocol'] = "REQUEST_URI"

更換 $config['uri_protocol'] ="AUTO"在.htaccess

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]` 

編輯的域下託管網站在XA中MPP

編輯C:\Windows\System32\drivers\etc\hosts(拖放文件到記事本) 在文件的最後添加這一行 127.0.0.1 www.test.com

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

NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "Fullpath/xampp/htdocs/Projectname" ServerName test.com ServerAlias www.test.com </VirtualHost>

添加這些代碼

確保使用您的確切路徑替換完整路徑。重啓apache重新啓動瀏覽器並輸入www.test.com

你可以看到你的項目&然後檢查重寫。

+0

它不工作我以前試過,:( –

相關問題