codeIgniter htaccess的mod_rewrite的工作不正常 [英] CodeIgniter htaccess mod_rewrite not working properly

查看:261
本文介绍了codeIgniter htaccess的mod_rewrite的工作不正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让网址 http://127.0.0.1/dev/blog/welcome 但是当我键入它改变了网址 http://127.0.0.1/开发/博客/ index.php文件/欢迎

I'm trying to make the url into http://127.0.0.1/dev/blog/welcome but when I type that it changes the url to http://127.0.0.1/dev/blog/index.php/welcome

但是当我做的http://127.0.01/dev/blog//welcome 它保持这样出于某种原因,

But When I do http://127.0.01/dev/blog//welcome it stays like that for some reason.

我的.htaccess是

my .htaccess is

RewriteEngine On
RewriteBase /dev/blog
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]

和我的config.php配置

and my config.php is configured

$config['base_url'] = 'http://127.0.0.1/dev/blog/';
$config['index_page'] = '';

呵呵,我也检查mod_rewrite的是,我使用WAMP

Oh, and I did check if mod_rewrite is on and I'm using WAMP

另一个信息:我使用的是Firefox,但是当我使用IE浏览器(9)它不会改变从网址 http://127.0.0.1/dev/blog/welcome http://127.0.0.1/dev/blog/index.php/welcome

Another info: I'm using Firefox but when I use IE(9) It doesn't change the url from http://127.0.0.1/dev/blog/welcome to http://127.0.0.1/dev/blog/index.php/welcome

推荐答案

有关你的重写规则,添加NC和QSA标志。该QSA确保查询字符串追加。除非你打算codeIgniter管理你的CSS文件,图像和robots.txt的,离开了倒数第二行了。

For your RewriteRule, add the NC and QSA flags. The QSA ensures that query strings are appended. Unless you are planning on CodeIgniter manage your css files, images, and robots.txt, leave out the penultimate line too.

试试这个:

RewriteEngine On
RewriteBase /dev/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

另外,检查你的 uri_protocol 在config.php。我有一些问题,WAMP没有检测到它正确,并且有最幸运用它设置而不是 AUTO <到 PATH_INFO / code>。

Also, check your uri_protocol in config.php. I've had some problems with WAMP not detecting it properly, and have had the most luck with setting it to PATH_INFO instead of AUTO.

这篇关于codeIgniter htaccess的mod_rewrite的工作不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆