2015-02-11 77 views
0

修復了它。在文件上做了一些小改動。它可以在下面看到。.htaccess文件無法正常使用path_info和/或獲取方法

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*) index.php?$1 [NC,QSA,L] 

我一直在嘗試了一整天來解決我遇到的問題。我有一個簡單的重寫的URL就像

http://example.com/about/?req=true 
http://example.com/index.php/about/?req=true 

它工作在我的本地沒有問題,這個.htaccess文件,但是當我把它上傳到服務器,我得到這個「沒有輸入文件中指定的」錯誤。您可以在下面看到.htaccess文件的內容。

RewriteEngine on 

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

我嘗試不同的事情,我在互聯網包括添加php.ini文件這臺cgi.fix_pathinfo 1上發現的,但他們沒有工作,除了一個和一個不讀取請求字符串。你可以在下面看到。

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

在此先感謝。

+0

你想重寫'http://example.com/about/?req = true'到 'http://example.com/index.php/about/?req = true'?一個文件下面的目錄怎麼能工作(甚至在一個語言環境機器上)?它不應該是這樣的嗎? 'http://example.com/about/index.php?req = true'或者像這樣的'http://example.com/index.php?req = true&page = about'? – serjoscha 2015-02-11 12:28:34

+0

@serjoscha我認爲你錯了。我在這裏要做的是使用$ _SERVER ['path_info']以更好的方式處理用戶友好的網址。 – 2015-02-11 12:30:50

回答

-1

首先關閉所有檢查阿帕奇重寫模塊是否啓用或不 如果啓用然後ü可以在URL

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /base_directory_name/ 
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /base_directory_name/index.php [L] 
</IfModule> 

使用此代碼隱藏的index.php與我認爲這將幫助ü。