[英]Codeigniter URL rewriting not working
I'm using the following .htaccess file to rewrite the URL's without index.php: 我正在使用以下.htaccess文件重写不含index.php的URL:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
The site is uploaded on my VPS, and when I enter it on, let's say: 该网站已上传到我的VPS,当我输入该网站时,可以说:
http://1.1.1.1/~admin/
it works fine. 它工作正常。 Now when I want to navigate through the website to for instance:
现在,当我想浏览网站时,例如:
http://1.1.1.1/~admin/welcome
it gives me the following error message: 它给了我以下错误信息:
The requested URL /home/admin/public_html/index.php/welcome was not found on this server.
Now when I access the welcome controller with the index.php in the URL: 现在,当我使用URL中的index.php访问欢迎控制器时:
http://1.1.1.1/~admin/index.php/welcome
It works fine again. 它再次正常工作。 What is going wrong here?
这是怎么了?
I use this: 我用这个:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
The "?" “?” after index.php is required for godaddy.
之后,godaddy需要使用index.php。 See this link: https://github.com/EllisLab/CodeIgniter/wiki/Godaddy-Installation-Tips
看到此链接: https : //github.com/EllisLab/CodeIgniter/wiki/Godaddy-Installation-Tips
服务器上不存在路径/ welcome,重写应类似于:
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
etc. 等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.