2010-12-23 84 views
0

我使用雪豹,我有我的本地市場環境,我試圖擺脫在URL中的index.php的...這裏是我的.htaccess和笨不工作

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

我的配置文件有這個

$config['index_page'] = ""; 

但是當我訪問網頁時沒有的index.php它不工作

這個作品

http://localhost/ci_example/index.php/site 

這並不

http://localhost/ci_example/site 

我試圖按照this

也許我需要做一些與本地的conf文件...但我真的不知道什麼,我不知道如何重新啓動apache命令行...任何想法

+0

已與apache配置混淆? – yoda 2010-12-23 01:22:12

+0

我想現在...我將AllowOverride全部更改爲無 – Trace 2010-12-23 01:37:45

回答

4

你是什麼意思,當你說「它不工作」?你有錯誤嗎?白屏? 500錯誤?

您是否確定您的httpd.conf文件的AllowOverride設置設置爲All?如果不是,它可能不會使用您的.htaccess文件,這意味着重寫規則不會被使用。

0

嘗試在.htaccess文件

RewriteEngine On 
RewriteBase /ci_example 
0

這裏添加RewriteBase的東西,對我的作品在OS X

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

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

以上應該爲你工作,而無需任何修改。如果您正在託管文件夾,例如http://myserver.com/my_app/然後在兩個地方更改/index.php/my_app/index.php

一定要進入config.php文件並更改url_protocolPATH_INFO

1

試試這個.htaccess代碼&更改基本路徑,它將適用於所有godaddy和其他hostnigs。


選項

選項-Multiviews 選項+的FollowSymLinks

啓用國防部重寫

RewriteEngine敘述在

您的網站的根目錄的位置

如果寫作爲子目錄ctories,你應該輸入/子目錄

RewriteBase/winscore

刪除用戶訪問CodeIgniter的系統文件夾。

此外,這將允許您創建一個System.php控制器,

之前,這將不會成爲可能。

如果您已將系統文件夾重命名,則可以替換'系統'。

的RewriteCond%{REQUEST_URI} ^系統。* 重寫規則^(。*)$ /index.php?/$1 [L]

檢查是否用戶正試圖訪問一個有效的文件,

諸如圖像或CSS文件,如果這不是真的它發送

請求到index.php

的RewriteCond%{REQUEST_FILENAME}!-f 的RewriteCond%{REQUEST_FILENAME}!-d

這個條件的允許訪問圖像和CSS

文件夾,並且robots.txt文件

的RewriteCond $ 1→!(index.php文件|圖片|的robots.txt | CSS)

重寫規則^(。*)$的index.php?/ $ 1 [L]


0

拷貝到你的.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /CI_FOLDER/ 
#CI_FOLDER is the Location of your CI files. 

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#'system' can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#When your application folder isn't in the system folder 
#This snippet prevents user access to the application folder 
#Submitted by: Fabdrol 
#Rename 'application' to your applications folder name. 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn't true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 



</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule>