2013-11-22 132 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