Forum Moderators: mack

Message Too Old, No Replies

Strange htaccess file problem

         

Duckman2000

10:08 pm on Oct 4, 2003 (gmt 0)

10+ Year Member


I have been trying to create a working htaccess file for a subdirectory to do 2 things:

1. Create a Custom Error Page
2. Redirect 301 one old non-existing page

The htaccess file works with either one line script, but when I put both lines in the same file I get an Internal Server Error.

The two lines of code are below. 404.html is the name of the custom error page and old.html is the now non-existing page and testpage.html is the new page to be directed to. Also muliple error page lines of code (say for ErrorDocument 404... and ErrorDocument 40x... DO work together in the same htaccess file..tried this to make sure there wasn't a restriction about using more than 1 line in the file).

I have also REVERSED the order of the 2 lines below and when I do that the ErrorDocument 404 function works but the redirect 301 is ignored (but no Internal Server Error).

Sample Code Tried That Doesn't Work (mydomain not the real address):

Redirect 301 /testfolder/old.html http://www.mydomain.com/testfolder/testpage.html
ErrorDocument 404 http://www.mydomain.com/testfolder/404.html

IMPORTANT NOTE: If either line by itself is put in the htaccess file, then that function works, but if BOTH lines are included in the htaccess file then the Internal Server Error happens. There are NO other lines of code in the htaccess file. Since both lines work individually I would assume the lines of code are correct?

I suspect that maybe my hosting company (Verio) for some reason doesn't support both lines together? Or is there a simple rule I am missing here?

Thanks in advance!

jdMorgan

3:37 am on Oct 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Duckman2000,

Verio supports some fairly awesome .htaccess stuff - I haven't run into any restrictions that aren't documented as directory-level (.htaccess) "built-in" restrictions in the documentation itself. I've got a few "Bronze" accounts with shared server/unique IP address-type setups, so that's my reference.

I suspect, but can't be sure, that the problem is in your ErrorDocument directives; The Apache ErrorDocument documentation [httpd.apache.org] basically states that ErrorDocument paths should usually be local, i.e.

ErrorDocument 404 /testfolder/404.html

not a full URL. If a full URL is specified, Apache will not respond with a 404 error code, but rather, with a 302.

If cleaning that up doesn't fix it, please let us know and we'll go from there. Also, you might want to post the raw server error log line showing the 500 error, usually at www.yourdomain.com/stats/error_log on a Verio account, and note whether your raw access log shows the server going into a loop and redirecting multiple times.

Jim

Duckman2000

3:43 pm on Oct 7, 2003 (gmt 0)

10+ Year Member



Thanks Jim for the response...tI ried just the local URL and had the same results.

The saga continues. When I put both lines in the htaccess file (no other lines are in the file):

Redirect 301 /testfolder/old.html [mydomain.com...]
ErrorDocument 404 /testfolder/404.html

I get this error in the error log:

[alert] .htaccess: Redirect takes two or three arguments, an optional status, then document to be redirected and destination URL.

If the same Redirect 301 line is the only line in the htaccess file, it does work.

It is almost as if the program is not recognizing the seperator character between the two lines (but I have tried putting multiple ErrorDocument statements in the file and they do work).

Any Ideas? IS there a rule that you cannot use a 301 and 404 statement in an htaccess file? Or is it something with Verio's htaccess implementation?

Thanks, Bob

jdMorgan

10:10 pm on Oct 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Duckman2000,

> IS there a rule that you cannot use a 301 and 404 statement in an htaccess file?
> Or is it something with Verio's htaccess implementation?

No I've got several ErrorDocument directives and more than a dozen Redirects in a working .htaccess file on a Verio host.

Because of the comment you made about the alert message, I'm wondering if your text editor is doing something funny. On Windoze, it should work fine if you use NotePad, or even Word as long as you save as US-ASCII with LF Only selected as the Line Ending.

And as long as the redirect target page exists, the order of your two directives should make no difference.

You might also want to try using RedirectPermanent instead of Redirect 301 -- They accomplish the same thing in different ways, but maybe they will behave differently and reveal a clue to the problem.

I'm hoping you have a .htaccess file format problem, because otherwise this is a really strange problem...

Jim