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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?