2015-11-23 39 views
1

所以我用我搜索在這裏.htaccess文件,我用這個:Codeigniter,Windows,XAMPP,如何使用htaccess來擺脫尾部斜槓?

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

通緝哪個擺脫index.php文件中。我在codeigniter目錄中有.htaccess文件。該網站顯示細膩使用這個鏈接與結尾的斜線:

http://localhost/codeigniter/home/ 

但要鏈接但沒有斜槓home.php顯示我的網站看起來像它一直沒有聯繫到css文件之後。有什麼建議麼?如果說有什麼區別

$config['index_page'] = ""; 

而且,在我config.php文件我已經編輯索引頁。

回答

1
RewriteEngine on 

# Next two lines get rid of trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ $1 [L,R=301] 

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

也BASE_URL在配置文件應該是

$config['base_url'] = 'http://localhost/codeigniter/'; 

你應該從後視圖文件的代碼,讓我們確定是怎麼回事。我假設你正在使用某種相對路徑。嘗試使用類似的東西:

<link rel="stylesheet" type="text/css" href="<?php echo base_url('resources/css/main.css'); ?>"> 

不要忘記加載URL助手之前。