2011-04-11 66 views
0

我有這樣的site,當你點擊在中心去,我把它去這個網址取出的index.php不工作

http://dev.posnation.com/welcome/redirect 

這是不是歡迎控制器和正確的頁面重定向操作。正確的URL是

http://dev.posnation.com/index.php/welcome/redirect 

我笨結構是這樣的

[email protected] 1 tamer staff 225 Apr 11 13:09 .htaccess 
[email protected] 18 tamer staff 612 Apr 8 17:26 application 
drwxr-xr-x 11 tamer staff 374 Apr 11 09:46 css 
[email protected] 6 tamer staff 204 Mar 24 14:20 graphics 
drwxr-xr-x 17 tamer staff 578 Apr 11 09:54 js 
[email protected] 10 tamer staff 340 Apr 7 12:20 system 
[email protected] 16 tamer staff 544 Apr 7 12:20 user_guide 

與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 

任何想法

回答

1

Codeigniter Wiki提供了以下鷸:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

    #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> 

在您的配置,請相應地更改以下變量:

config['uri_protocol'] = 'QUERY_STRING'; //set to QUERY_STRING 

$config['index_page'] = ""; //Remove index.php 

確保你的Apache的mod_rewrite模塊被加載(只如果上面拋出404)。

有足夠多的問題也可能是在http://codeigniter.com/wiki/mod_rewrite/

+0

雖然這會產生site.com/index.php/controller/method嗎? – Cogicero 2011-04-11 17:31:33

+0

沒有工作......也許它有一些與我的index.php和我的系統和應用程序文件夾生活 – Trace 2011-04-11 17:31:54

+0

這主要是重定向到URI的index.php頁面,請確保您設置爲AUTO在您的路線和從配置文件中的base_url中刪除'index.php',你的系統目錄是服務器端,這應該沒有任何作用。 – RobertPitt 2011-04-11 17:33:17

2

你錯過了之後的RewriteCond一個重寫規則行。嘗試

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] 
+0

仍然沒有。可能它與我的index.php和我的系統和應用程序文件夾的位置有關 – Trace 2011-04-11 17:33:07

+0

你說你的index.php出了一個目錄?什麼是目錄的名稱,或者你能說明你的意思? – Cogicero 2011-04-11 17:36:24

+0

你有沒有從配置文件base_url中刪除index.php? – Cogicero 2011-04-11 17:39:22

0

它有時會混淆什麼會起作用。嘗試添加此作爲最後一行

RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
0

我有類似的問題。確保你得到了RewriteRule的權利。不同的方法也需要不同的方法來捕捉變量。我已經看到了兩個,其中一個基本上將$ _GET數組變量應用於示例中給出的url變量。

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 

RewriteRule ^(.*)$ ./index.php?url=$1 [L,QSA] 

你能趕上分別爲「M:

echo $_SERVER['PATH_INFO']; 

echo $_GET['url']; 

CodeIgniter使用的index.php/$ 1嗎?。這對我造成了問題。

相關問題