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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:40:56+00:00 2026-06-12T09:40:56+00:00

I am working on an open source project. I do not know what directory

  • 0

I am working on an open source project. I do not know what directory this project will be installed in on the end user. I need to add rules to the .htaccess file created for my project, so that 404’s and other point to a specific file, in the root of my project. The setup script is called in a folder called “setup”, in relation to the root folder like such root/setup/index.php.

The path I use to direct 404’s from the .htaccess in the root to errorcode.php (also in the root folder) is this:

$installURL = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);
$save= $installURL;
$str = str_replace( '/setup', '', $save ); //remove /setup/
$installURL= $str ;

I then open the .htaccess file and make my rules like such:

$fp = fopen("../.htaccess", "a");
fwrite($fp, "\n\n# ErrorDocuments \n");
fwrite($fp, "ErrorDocument 400 ". $installURL."/errorcode.php?error=400 \n");

There’s a list of rules for all of the 400 HTTP headers.

This has worked for me for about a month now. Today, I started getting server errors, and the log file says the following:

[Thu Oct 04 11:56:59 2012] [notice] cannot use a full URL in a 401 ErrorDocument directive --- ignoring!
[Thu Oct 04 11:56:59 2012] [alert] [client 127.0.0.1] C:/wamp/www/Project-BlackHawk/.htaccess: Unsupported HTTP response code 428, referer: http://localhost/Project-BlackHawk/setup/index.php

My question is, am I supposed to use something like this for the path to ErrorDocument:

$installURL = dirname($_SERVER['SCRIPT_NAME']);
$save= $installURL;
$str = str_replace( '/setup', '', $save ); //remove /setup/
$installURL= $str ;
  • 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-12T09:40:57+00:00Added an answer on June 12, 2026 at 9:40 am

    It sounds like you need to remove the http://localhost part from your ErrorDocument directive. So $_SERVER['SCRIPT_NAME'] would probably do that for you, so would $_SERVER['REQUEST_URI'].

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

Sidebar

Related Questions

I'm working on a project where I need to generate end-user documentation for a
We use SVN at work (ie. this is not an open-source project) and have
I'm working on a project that I will release as open source, but it
I am working on an open source project which can use a number of
I'm working on a database with mysql 5.0 for an open source project it's
I'm working on a Qt/C++ open source project that uses MySQL databases. One class
I'm working on a open source project where a sequence of events might look
I am working on a Cross-Platform open-source project. My application is going to support
I'm working on an open source project. The original project contains comments in russian
I have recently started working on some open source project which I found relevant

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.