啟用 fcgid 時重寫 URL 時出現的問題

啟用 fcgid 時重寫 URL 時出現的問題

首先是有關我的伺服器的一些資訊:

阿帕契2版本:2.4 模組: php5:禁用; 改寫:已啟用; 蘇執行程式:已啟用; fcgid:已啟用;

PHP版本:5.3.3

我目前正在使用 CodeIgniter 創建一個網站,我想重寫我的 URL 以從瀏覽器中「隱藏」index.php

我已經在這裡嘗試過這兩個解決方案,但它不起作用:http://takeitoffroad.blogspot.ch/2008/08/codeigniter-issues-with-htaccess-to.html

我的 .htaccess 檔案目前如下所示:

編輯:如果我將它放入我的vHost 的conf 文件中,我使這個工作正常,但是如果我在.htaccess 中使用它,它不會執行它應該執行的操作...激活的跟踪,記錄如下:

<IfModule mod_rewrite.c>
    RewriteEngine On

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


[Wed May 22 09:42:18.665868 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] add path info postfix: /var/customers/webs/cust/sdom/domain/main -> /var/customers/webs/cust/sdom/domain/main/forgot
[Wed May 22 09:42:18.665898 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] strip per-dir prefix: /var/customers/webs/cust/sdom/domain/main/forgot -> main/forgot
[Wed May 22 09:42:18.665905 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] applying pattern '^(.*)$' to uri 'main/forgot'
[Wed May 22 09:42:18.665924 2013] [rewrite:trace4] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] RewriteCond: input='/var/customers/webs/cust/sdom/domain/main' pattern='!-f' => matched
[Wed May 22 09:42:18.665941 2013] [rewrite:trace4] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] RewriteCond: input='/var/customers/webs/cust/sdom/domain/main' pattern='!-d' => matched
[Wed May 22 09:42:18.665949 2013] [rewrite:trace2] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] rewrite 'main/forgot' -> 'index.php/main/forgot'
[Wed May 22 09:42:18.665972 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] add per-dir prefix: index.php/main/forgot -> /var/customers/webs/cust/sdom/domain/index.php/main/forgot
[Wed May 22 09:42:18.665982 2013] [rewrite:trace2] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] strip document_root prefix: /var/customers/webs/cust/sdom/domain/index.php/main/forgot -> /index.php/main/forgot
[Wed May 22 09:42:18.665988 2013] [rewrite:trace1] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1916d60/initial] [perdir /var/customers/webs/cust/sdom/domain/] internal redirect with /index.php/main/forgot [INTERNAL REDIRECT]
[Wed May 22 09:42:18.666041 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1926cc0/initial/redir#1] [perdir /var/customers/webs/cust/sdom/domain/] add path info postfix: /var/customers/webs/cust/sdom/domain/index.php -> /var/customers/webs/cust/sdom/domain/index.php/main/forgot
[Wed May 22 09:42:18.666052 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1926cc0/initial/redir#1] [perdir /var/customers/webs/cust/sdom/domain/] strip per-dir prefix: /var/customers/webs/cust/sdom/domain/index.php/main/forgot -> index.php/main/forgot
[Wed May 22 09:42:18.666058 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1926cc0/initial/redir#1] [perdir /var/customers/webs/cust/sdom/domain/] applying pattern '^(.*)$' to uri 'index.php/main/forgot'
[Wed May 22 09:42:18.666069 2013] [rewrite:trace4] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1926cc0/initial/redir#1] [perdir /var/customers/webs/cust/sdom/domain/] RewriteCond: input='/var/customers/webs/cust/sdom/domain/index.php' pattern='!-f' => not-matched
[Wed May 22 09:42:18.666076 2013] [rewrite:trace1] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c1926cc0/initial/redir#1] [perdir /var/customers/webs/cust/sdom/domain/] pass through /var/customers/webs/cust/sdom/domain/index.php
[Wed May 22 09:42:18.666130 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] add path info postfix: /var/customers/webs/cust/sdom/domain/main -> /var/customers/webs/cust/sdom/domain/main/forgot
[Wed May 22 09:42:18.666149 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] strip per-dir prefix: /var/customers/webs/cust/sdom/domain/main/forgot -> main/forgot
[Wed May 22 09:42:18.666156 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] applying pattern '^(.*)$' to uri 'main/forgot'
[Wed May 22 09:42:18.666167 2013] [rewrite:trace4] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] RewriteCond: input='/var/customers/webs/cust/sdom/domain/main' pattern='!-f' => matched
[Wed May 22 09:42:18.666184 2013] [rewrite:trace4] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] RewriteCond: input='/var/customers/webs/cust/sdom/domain/main' pattern='!-d' => matched
[Wed May 22 09:42:18.666191 2013] [rewrite:trace2] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] rewrite 'main/forgot' -> 'index.php/main/forgot'
[Wed May 22 09:42:18.666198 2013] [rewrite:trace3] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] add per-dir prefix: index.php/main/forgot -> /var/customers/webs/cust/sdom/domain/index.php/main/forgot
[Wed May 22 09:42:18.666206 2013] [rewrite:trace2] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] strip document_root prefix: /var/customers/webs/cust/sdom/domain/index.php/main/forgot -> /index.php/main/forgot
[Wed May 22 09:42:18.666212 2013] [rewrite:trace1] [pid 24571] mod_rewrite.c(466): [client 193.134.254.25:61594] 193.134.254.25 - - [domain.example.com/sid#7fc8c1882480][rid#7fc8c191cd90/subreq] [perdir /var/customers/webs/cust/sdom/domain/] internal redirect with /index.php/main/forgot [INTERNAL REDIRECT]

如果我檢查最後一行(內部重定向),它與我直接瀏覽到/index.php/main/forgot 是完全相同的行,那麼它會起作用......我想說它必須有某事要做與FCGID

我很高興有任何可能的解決方案。如果您想了解更多信息,請發表評論,我會添加它

謝謝

沙維耶爾

答案1

好的找到了解決方案。我不知道確切的原因,但是在index.php/$1 中的斜線之前添加一個問號現在工作正常......昨天不起作用O_o

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

誰能向我解釋為什麼它必須在那裡?

相關內容