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 7413057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:38:13+00:00 2026-05-29T06:38:13+00:00

What I basically want to do is redirect any 404 requests to /404/ but

  • 0

What I basically want to do is redirect any 404 requests to /404/ but then I would like to have it ‘pull’ the page to index.php?error=404, whilst leaving the URL as /404/ – then I can get the referer using PHP (using $_SERVER[‘HTTP_REFERER’]`).

I believe that the ReWrite rules should go prior to the ErrorDocuments, so my .htaccess file looks like the following:

RewriteRule ^404/$ /index.php?error=404
ErrorDocument 404 /404/

I know that I’m probably doing something fundermentally wrong with the above, since the 404 page/$_SERVER gets no referer URL (probably because of ErrorDocument).

The index.php page gets all the content routed through it (something very standard, I gather) and sends performs a header redirect to /404/ if/when a page/file is not found. Though if someone were to enter the URL into the browser incorrectly, I would like to get the original request, though since the page is being redirected anyway, should that be still be the referer in PHP?

  • 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-29T06:38:13+00:00Added an answer on May 29, 2026 at 6:38 am

    I suggest you do it differently by directly using a error.php file:

    ErrorDocument 404 error.php
    

    You can then use that file as a proxy injecting all needed information into index.php. If you need to find out the apache status code (and additional useful information), take a look into the $_SERVER superglobal array.

    Doing it this way gives you a better level of control and you can deal with server-differences easier in case you need to migrate your application from one server to another.

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

Sidebar

Related Questions

I basically want to rewrite any request starting with foo/ to foo/index.php?url= . For
I want to rewrite /home to the index.php and /edit to edit.php , but
I have a table called Subscriptions. I'd like to redirect any LINQ select from
I'm making a register page, signup.php, and basically what I want it to do
I want to create a single page such as this: http://www.mywebsite.com/special/index.html But anything in
basically what i want is redirect al request to use HTTPS instead of http
I want to redirect the output of some Windows program directly to gvim basically
I basically want something like: TextView Button Button . . . TextView TextView SeekBar
I want to write a MobileSubstrate ( http://www.iphonedevwiki.net/index.php/MobileSubstrate ) addon that takes every HTTP
I have a shopping cart flow like this: Page 1 . Choose Products Page

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.