dongqiong8021 2012-04-26 23:47
浏览 54
已采纳

CodeIgniter htaccess mod_rewrite无法正常工作

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

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

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]

and my config.php is configured

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

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

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

  • 写回答

3条回答 默认 最新

  • dongzhan2029 2012-04-26 23:59
    关注

    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.

    Try this:

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

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用