website/apache question

I know I’m going to feel dumb when I hear the answer to this, but at least I’ll be able to do it. I want to set up a website such that when the main page of the site is called (aka http://mysite.com), the website sees no files there and sends a 404 (or 403) error. I want my .htaccess file to catch this error and redirect it to a script that I have neatly stored elsewhere. I believe I have set up the .htaccess file correctly, and I opened the Apache config file to turn on the .htaccess overrides (set to all), but I am still getting a Forbidden error. What am I missing?

Your question is not very clear. Do you want to return a 404 error or redirect to a script? Or do you want to redirect to a script whenever there’s a 404 error? Can you restsate the question more clearly and paste the relevant portions of your conf file and .htaccess?

i want it to always redirect to a script. my htaccess file has the following in it:

ErrorDocument 404 ./scripts/parseurl.php
ErrorDocument 403 ./scripts/parseurl.php
Options -Indexes

I don’t want to do a simple redirect because I want parseurl.php to be called EVERY time my site is hit, no matter what is beyond the .com part of the url.

Your .htaccess is fine.

What’s throwing me is that you say you’re getting a Forbidden error, not a 404?

It sounds like you’re being redirected properly, but the parseurl.php script doesn’t have permissions set properly (or perhaps the scripts directory).

Your .htaccess should be fine.

What’s throwing me is that you say you’re getting a Forbidden error, not a 404?

It sounds like you’re being redirected properly, but the parseurl.php script doesn’t have permissions set properly (or perhaps the scripts directory).

Another thing to try is putting the full path to script in .htaccess.

You are both correct. It’s a 403. I apologize for not clairifying. I have the permissions for parseurl.php set to 777. Same for the directory. I do intend to change it eventually. Fortunately, this is on a Linux server. I wouldn’t know how to go about this on NT.

First, you don’t want to set anything to 777; change the permissions on your PHP script to 755.

Second, do you have PHP installed in CGI mode, or compiled into Apache as a module? I’m not very familiar with PHP, but if it’s the latter, you may need to do some additional configuration to get PHP set up properly.

I believe it’s compiled into apache. Not sure. Any PHP experts know what to do if this is the case?