drbfxb977777 2013-01-22 20:39
浏览 46
已采纳

Codeigniter:重写以删除index.php不起作用

I've just uploaded my website from my local server (XAMPP). It was working locally, but for some reason the rewrite to add index.php to my SEF URL's is not working in my public server. This is what I've got right now:

# Avoid listing directory
Options -Indexes

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on

# manage language segment 
RewriteRule ^(es|en)/(.*) $2?lang=$1 [L]

# code that allows to get rid of index.php from URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

</IfModule>

These URL's work:

www.example.com

www.example.com/index.php/aboutme

while URL's like this generate a 500 error:

www.example.com/aboutme

Here's another combination of condition and rule I tried to solve the index.php removal:

RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml) 
RewriteRule ^(.*)$ index.php/$1 [L]

But it generates a 500 error for any URL without index.php, including the root URL www.example.com

Could you help me fix this?

  • 写回答

1条回答 默认 最新

  • duanchen7036 2013-01-22 20:46
    关注

    There seems to be a typo in your RewriteRule.

    Try this:

    RewriteCond $1 !^(index.php|css|img|scripts|ckeditor|robots.txt|sitemap.xml) 
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    It works for us with Code Igniter. The only difference is the slash infront of index.php when compared to your second examples.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器