我正在使用以下.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
再次正常工作。这里出了什么问题?
答案 0 :(得分:1)
我用这个:
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
答案 1 :(得分:0)
服务器上不存在路径/ welcome,重写应该类似于:
RewriteRule ^(.*)$ index.php?$1 [L]
答案 2 :(得分: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>
答案 3 :(得分: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
等。