2013-11-22 131 views
1

我使用下面的.htaccess文件重寫URL的無index.php文件:笨URL重寫不工作

RewriteEngine on 

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

該網站上傳我的VPS,當我進入它,讓我們說:

http://1.1.1.1/~admin/ 

它工作正常。現在,當我想通過網站導航比如:

http://1.1.1.1/~admin/welcome 

它給了我下面的錯誤信息:

The requested URL /home/admin/public_html/index.php/welcome was not found on this server. 

現在,當我在index.php訪問歡迎控制器的URL :

http://1.1.1.1/~admin/index.php/welcome 

它再次正常工作。這裏出了什麼問題?

回答

0

的路徑/歡迎不存在於服務器上,重寫應該是這樣的:

RewriteRule ^(.*)$ index.php?$1 [L] 
+0

不,還是一樣的錯誤信息。 – user108287

+0

重寫應該通過將welcome轉換爲參數來產生正確的路徑,/ home/admin/public_html/index.php?var1 = welcome – Daan

+0

它不會。它給了我這個信息:在這臺服務器上找不到請求的URL /home/admin/public_html/index.php。 – user108287

0
<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

<IfModule mod_php5.c> 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_php5.c> 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

</IfModule> 
+0

不適用於我。同樣的錯誤訊息 – user108287

0
I wrote this: Trouble Shooting Codeigniter on localhost 

http://garyjohnson53.wordpress.com/2013/10/31/trouble-shooting-codeigniter-on-localhost/ 



Its not a polished article, but it walks you through a few of the common things with codeigniter. 

MVC URI segments 
example.com/class/method/id/ 

your condif.php usually in application/config 
your index.php 
your .htacess 
Alias and apache