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

  • Home
  • SEARCH
  • 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 7551761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:34:47+00:00 2026-05-30T10:34:47+00:00

I am using mod_rewrite in my PHP framework to redirect user-friendly links to one

  • 0

I am using mod_rewrite in my PHP framework to redirect user-friendly links to one main entry point of the application. The .htaccess file I am using looks like that:

<IfModule mod_rewrite.c>
    Options FollowSymLinks

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
 </IfModule>

Now, I would like to use that rule with the ErrorDocument directive. How should I do this? My framework sets the response code to 404 when there’s a controller missing:

    /**
     * Sets the HTTP response code.
     *
     * @param int $errorCode The response code to return. <b>Supported codes: </b>301, 307, 400, 401, 403, 404, 500,
     * 501, 502, 503
    */
    function setHTTPStatus($errorCode) {
        $httpStatusCodes = array(301 => 'Moved Permanently', 307 => 'Temporary Redirect', 400 => 'Bad Request',
            401 => 'Unauthorized', 403 => 'Forbidden', 404 => 'Not Found', 500 => 'Internal Server Error',
            501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable');

        if (array_key_exists($errorCode, $httpStatusCodes)) {
            header("HTTP/1.0 $errorCode $httpStatusCodes[$errorCode]", true, $errorCode);
            exit;
        }
    }

I tried adding the line ErrorDocument 404 /index.php?url=404 and ErrorDocument 404 /error but none seem to have worked and I get the default browser’s error page.

What is wrong?

Thank you.

  • 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-05-30T10:34:48+00:00Added an answer on May 30, 2026 at 10:34 am

    There is no easy way to do this via the .htaccess file. Once you’re in php code land, apache has processed through the .htaccess file and httpd.conf files and made a handoff to the frameworks front
    controller–in this case the index.php file for the framework.

    What framework are you using?

    The best way to handle this is to use the frameworks error handling, not the baked-in apache handling. The apache 404 is fine for any non-framework served pages like an image, css, js, etc… Your framework should have a configuration file somewhere to set the default error view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using .htaccess and mod_rewrite in my little PHP framework. It's working nicely,
I want to redirect the following url: http://abc.com/colleges/first.php to http://abc.com/first.php using mod_rewrite and .htaccess
I've been using mod_rewrite in my htaccess file to rewrite my urls and I've
I have a PHP-Apache application using mod_rewrite for clean URLs. I am having a
I would like redirect addresses that start with: en.example.com/somefile.php to: example.com/somefile.php?language=en Using mod_rewrite module
It is possible to rewrite my url using mod_rewrite and htaccess where a user
I'm wanting to rewrite Word Press urls using mod_rewrite in my .htaccess file in
I made one website xyz.com using php codeigniter framework. This website has modules, so
I'm using mod rewrite to rewrite some dynamic php links. Such as file.php?id=1 equals
I'm using mod_rewrite to redirect on URLs like: mysite.com/123 RewriteEngine On RewriteRule ^([0-9]+)$ /n/index.php?id=$1

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.