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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:03:09+00:00 2026-05-30T06:03:09+00:00

I am attempting to write a .htaccess file to direct to and send index

  • 0

I am attempting to write a .htaccess file to direct to and send index with an error code. Example index.php?error404 or index.php?error501.

I can direct an error within the root directory using the code below.

ErrorDocument 404 index.php?error=404
ErrorDocument 501 index.php?error=501

Example http://www.domain.com/file_does_not_exist.php and this works.
Result http://www.domain.com/index.php?error=404

The problem is catching and sending to index.php errors from sub directories.

Example http://www.domain.com/directory_does_not_exist Or
http://www.domain.com/directory_and/file_does_not_exist.php.

The result is http://www.domain.com/directory_does_not_exist/index.php?error=404 and therefore the CSS for the index.php in broken.

I have attempted the code below with no success. I am trying to redirect back to the index.php by rewriting the URL.

RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^\/.\/\.php$ /index.php?s=$1 [R]

AND

RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^([/]?*)\.php$ /index.php?s=$1 [QSA,L]

Any help would be appreciated.

  • 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-30T06:03:11+00:00Added an answer on May 30, 2026 at 6:03 am

    No need to use rewriting; just use absolute urls in your ErrorDocument directives (begin them with a /):

    ErrorDocument 404 /index.php?error=404
    ErrorDocument 501 /index.php?error=501
    

    The docs show absolute urls in the examples:

    URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser. Examples::

    ErrorDocument 500 http://foo.example.com/cgi-bin/tester
    ErrorDocument 404 /cgi-bin/bad_urls.pl
    ErrorDocument 401 /subscription_info.html
    ErrorDocument 403 "Sorry can't allow you access today"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been attempting to write a VBA Script that can parse out other
I'm attempting to write an ASCII null character (nul) to a file from a
I am attempting to write some code that will expediently process video frames. I
I am attempting to match a URL like http://www.example.org/?h=b1c60d1bf7c7119fef9fc726068e1418166.xml or ?h=b1c60d1bf7c7119fef9fc726068e1418166.jsonp&callback=testing and re-write it
I'm attempting to write memory contents to a socket in chunks. I can write
I'm attempting to write my own Log4Net Glimpse plugin (so I can interface with
I am attempting to write a file to external storage in android. I keep
I am attempting to write some Java code that takes an image from a
I am attempting to write a two-pass algorithm incorporating some legacy code. I want
I'm attempting to write an application to extract properties and code from proprietary IDE

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.