Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:45:13+00:00 2026-06-12T18:45:13+00:00

So, I am playing with urls a bit with a PHP app I am

  • 0

So, I am playing with urls a bit with a PHP app I am building.

I am using mod_rewrite using .htaccess. Here is what that looks like:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1
</IfModule>

I thought if a URL was written like below:

http://localdomain.com/controller

I would expect ‘controller’ ending without issues as part of the $_SERVER[‘PATH_INFO’]. However, on Ubuntu 12.04 running Apache 2.2.22 I get a 404 Not Found error instead:

NOT FOUND
The requested URL /index.php/controller was not found on this server.

It appears that ‘controller’ is being properly addressed after a slash following index.php, but Does anyone have any idea why I am getting a 404 instead of the expected response?

Ultimately I am trying to capture the ‘controller’ to use in an MVC framework I am building.

In this case I have a very simple index.php with ONLY the following:

<?php
echo $_SERVER['PATH_INFO'];

Yet, I still get a 404 error instead of the expected path info.

NOTE: Going to just http://localdomain.com/ or http://localdomain.com/index.php work perfectly. mod_rewrite is on and working, and AllowOverride is set to All.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:45:17+00:00Added an answer on June 12, 2026 at 6:45 pm

    If you’re running apache 2.2.22, then your PHP code is now responsible for specifying the 200 response if the controller function was found.

    Apache 2.2.22 seems to take a different philosophy on rewrites compared to 2.2.14. Long story, but it makes sense. It assumes that if you’re rewriting to a front-controller like CodeIgniter does, then the PHP code is responsible for deciding whether the requested URI was found or not. Apache waits for the PHP code to send header(‘HTTP/1.1 200 OK’), and if it doesn’t then it sends header(‘HTTP/1.1 404 Not Found’).

    Interestingly, the actual content coming from your controller is probably sent in the response body too. But many HTTP clients ignore that if the response code was 404 (like MSIE, wget, etc.)

    The short version is that apache 2.2.14 (on platinum) is optimistic, assuming 200 unless otherwise specified by PHP, whereas apache 2.2.22 is pesimistic, assuming 404 unless otherwise specified by PHP.

    So somewhere in your code, you must place:

    header('HTTP/1.1 200 OK');
    

    This should be placed just after the front-controller has determined that the URI is valid and a class and method exists and can be called for this URI, but before the class and method are actually called.

    In CodeIgniter 2.1.3, it looks like this:

    // Added this line for Apache 2.2.22
    header('HTTP/1.0 200 OK');
    // Call the requested method.
    // Any URI segments present (besides the class/function) will be passed to the method for convenience
    call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm playing a bit with Javascript these days... I was shrinking some URLs using
I'm playing a bit in Java with the URLDecoder class to analyze some urls,
I'm playing with this combine.php file and it looks nice, but I'm wondering if
Playing with URLs, more specifically building them incrementally from other, discovered URLs. In doing
I'm new here I and need your help. I started playing with .htaccess and
right now i m using this code for playing youtube videos <?php // Replace
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
I am playing with mod_rewrite now, and have successfully enabled it. However, I need
I have the following code that I am playing with: <script type=text/javascript> var Dash
I need ur help for given subject. I am playing with htaccess rules first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.