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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:02:47+00:00 2026-05-20T11:02:47+00:00

My website needs a .htaccess file that will redirect a user to index.php when

  • 0

My website needs a .htaccess file that will redirect a user to index.php when a page is not found. However, I do not want Apache to send a 404 header with the document.

I asked this question earlier:
Apache .htaccess 404 error redirect

The command "ErrorDocument /index.php" produces the exact effect that I want, except that it sends a 404 header with the page. What can I do? Should I overwrite the 404 header with 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-20T11:02:48+00:00Added an answer on May 20, 2026 at 11:02 am

    Add this to your .htaccess file:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    
    1. enable rewrite
    2. check if requested file exists as a regualar file with size (not empty)
    3. check if requested file is link
    4. check if requested file is a directory
    5. if one of the previous 3 statements is true show that file
    6. otherwise go to index.php

    If the redirect to index.php happens u can get the requested uri by using $_SERVER["REQUEST_URI"] inside index.php

    • ‘-d’ (is directory) Treats the TestString as a pathname and tests if
      it exists and is a directory.
    • ‘-f’ (is regular file) Treats the TestString as a pathname and tests if
      it exists and is a regular file.
    • ‘-s’ (is regular file with size) Treats the TestString as a pathname
      and tests if it exists and is a
      regular file with size greater than
      zero.
    • ‘-l’ (is symbolic link) Treats the TestString as a pathname and tests if
      it exists and is a symbolic link.
    • ‘-F’ (is existing file via subrequest) Checks if TestString is a
      valid file and accessible via all the
      server’s currently-configured access
      controls for that path. This uses an
      internal subrequest to determine the
      check, so use it with care because it
      decreases your servers performance!
    • ‘-U’ (is existing URL via subrequest) Checks if TestString is a
      valid URL and accessible via all the
      server’s currently-configured access
      controls for that path. This uses an
      internal subrequest to determine the
      check, so use it with care because it
      decreases your server’s performance!

    More information: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

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

Sidebar

Related Questions

Currently i have url parameters like this http://www.website.com/index.php?user&page=edit And in index.php i have set
Currently I have a url like this http://<client_name>.website.com/index.php?function_name&cat=32 I want to set things up
I've built a nice website system that caters to the needs of a small
i want something like this the user enter a website link i need check
I have the following htaccess file: RewriteEngine On RewriteRule ^([^/]*)$ /bio.php?bio=$1 [L] I need
i've started using modrewrite under php - i wrote an .htaccess file and defined
I need to automate a process involving a website that is using a login
I need to build a prototype for an intranet website, and I want to
I'm trying to parse an xml file from a website. Let's say the website
The situation is as follows: there's a website that connects sellers and buyers, like

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.