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 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭