dsfs64664 2017-03-05 15:16
浏览 54
已采纳

Codeigniter页面加载在localhost上,但404加载在服务器上

If I go to:

http://localhost/entry

I see my test page. If I go to:

http://examplesite.com/entry

I get a 404 page. And I don't mean the Codeigniter 404 page but the default apache one. The code bases are identical.

The homepage works fine but any inner pages 404. This is the contents of my root .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes access to the system folder by users. Additionally this will allow you to create a System.php controller, 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # When your application folder isn't in the system folder. This snippet prevents user access to the application folder. Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    # Checks to see if the user is attempting to access a valid file, such as an image or css document, if this isn't true it sends the request to index.php.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

Mod rewrite is enabled on the server verified with phpinfo(). Am I missing something?

  • 写回答

2条回答 默认 最新

  • dsfjnxjlbqv9812 2017-03-05 15:39
    关注

    When you see Apache's 404 status page instead of CodeIgniter's 404, mod_rewrite is not active.

    phpinfo only tells you, if a module is loaded, not if it's configured properly. You can check reliably, if mod_rewrite is active, by adding garbage to your .htaccess inside <IfModule mod_rewrite.c>...</IfModule>. When it is active, you will get a 500 server error.

    To use mod_rewrite in .htaccess files, AllowOverride and Options must be set for the appropriate directory, e.g.

    AllowOverride FileInfo
    Options +FollowSymLinks
    

    or even

    AllowOverride All # default if <= 2.3.8
    Options All # this is the default
    

    Unrelated, but %{REQUEST_URI} starts with a slash, so the first two rules (with these RewriteConds) will never match.

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

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建