Codeigniter 应用程序中的 .htaccess 重定向问题
我对 codeigniter 和 .htaccess 有问题,我一直在这里寻找答案,但找不到它,所以我会感谢任何有关此问题的帮助:-)
在我的 index.php 上,第一行是这一行:
echo var_dump($_SERVER['REQUEST_URI']);
die();
我的 .htaccess 是这个:
ErrorDocument 404 /error
# Set default charset
AddDefaultCharset utf-8
RewriteEngine On
# From non-www to www
RewriteCond %{HTTP_HOST} ^paravegetarianos\.com$ [NC]
RewriteRule ^(.*)$ http://www.paravegetarianos.com/$1 [R=301,L]
# General
RewriteBase /
RewriteCond %{REQUEST_URI} !^(.+)\.(js|css|gif|png|jpg|jpeg|bmp|swf|txt|xml|htc|pdf|xls|doc|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
当我打开浏览器访问此网址时:
www.paravegetarianos.loc/comunidad/jonaypelluz/albums/danna/ca_1
它将重定向到:
http://www.paravegetarianos.loc/danna
并打印:
string '/danna' (length=6)
这是 access.log 中的行:
127.0.0.1 - - [28/Oct/2011:21:56:12 +0200] "GET /danna HTTP/1.1" 200 123
我想我的重写规则无法正常工作:- ) 谢谢!
I have a problem with codeigniter and the .htaccess, I have been looking for an answer here but I can't find it, so I would thank any help on this :-)
On my index.php, the first line is this one:
echo var_dump($_SERVER['REQUEST_URI']);
die();
My .htaccess is this one:
ErrorDocument 404 /error
# Set default charset
AddDefaultCharset utf-8
RewriteEngine On
# From non-www to www
RewriteCond %{HTTP_HOST} ^paravegetarianos\.com$ [NC]
RewriteRule ^(.*)$ http://www.paravegetarianos.com/$1 [R=301,L]
# General
RewriteBase /
RewriteCond %{REQUEST_URI} !^(.+)\.(js|css|gif|png|jpg|jpeg|bmp|swf|txt|xml|htc|pdf|xls|doc|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
And when I put on the browser to this url:
www.paravegetarianos.loc/comunidad/jonaypelluz/albums/danna/ca_1
it will redirect to:
http://www.paravegetarianos.loc/danna
and it will print:
string '/danna' (length=6)
and this is the line in the access.log:
127.0.0.1 - - [28/Oct/2011:21:56:12 +0200] "GET /danna HTTP/1.1" 200 123
I suppose my rewriting rules are not working properly :-) Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如已经说过的,我认为你必须看看你给出的代码之外的其他地方,因为我看不出它有什么问题。
如果您使用路由功能,请检查 /config/routes.php 中的自定义路由设置。
As already said, i think you must look elsewhere than in the codes you gave because i can't see nothing wrong with it.
If you are using routing feature, check the custom routes settings in /config/routes.php.