2012-09-21 56 views
0

我已經安裝codeigniter,我想從url刪除index.php當我訪問localhost/aplication/index.php。我已經設定取消註釋mod_rewrite.so從httpd.conf中連接這是我的.htaccess文件:無法刪除index.php與.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

的更迭,當我存取權限從本地主機/ aplication/index.php文件/數據/用戶/ 12而與此網址url localhost/aplication/data/users/12。

我該如何解決這個問題?

+2

請問您的虛擬主機配置[允許覆蓋](http://httpd.apache.org/docs/2.2/mod/core.html#AllowOverride)? – complex857

回答

1

嘗試關注關於codeignitor pretty urls的網頁。你的規則看起來是正確的,但是對於正則表達式我很糟糕。

有些事情要檢查是否mod_rewrite可通過使用phpinfo();.第三步,在該鏈接中討論使用a2enmod啓用mod_rewrite。並確保你重新啓動Apache。

0

檢查您的配置文件中應該有這樣一行:

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

您可以設置這個變量只是「」或者你可以完全註釋此行了,無論哪種方式,它是過程的一部分從codeigniter網址中刪除index.php。

0

你這是怎麼刪除的index.php:

htaccess文件在根文件夾:

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

管理一些靜態頁面,如:example.com/about,example.com/contact ,example.com/terms等

得配置路由文件並編輯:

//the controller that will be when it is exampl.com 
$route['default_controller'] = 'YOUR_MAIN_CONTROLLER_NAME_HERE'; 
//I creted this for pages that are created dynamically or for displaying error when I want 
$route['404_override'] = 'friendlyPages';