代码点火器URL重写不起作用


Codeigniter URL rewriting not working

我正在使用以下.htaccess文件重写不带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.

现在,当我使用URL中的index.php访问欢迎控制器时:

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

它又正常工作了。这里出了什么问题?

我使用这个:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L] 

对于godaddy,index.php后面的"?"是必需的。请参阅此链接:https://github.com/EllisLab/CodeIgniter/wiki/Godaddy-Installation-Tips

服务器上不存在路径/欢迎,重写应该类似于:

RewriteRule ^(.*)$ index.php?$1 [L]
<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>
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

等等。