.htaccess question - using %{HTTP_HOST} in rewrite output

Here is my .htaccess file:

RewriteEngine On
RewriteBase /

# zipcode
ReWriteRule ^([0-9]{5})-([a-z-]+)-jobs.*$ http://%{HTTP_HOST}/zip.php?zip=$1&tab=$2 [NC]

# 404 redirect to homepage
ErrorDocument 404 http://%{HTTP_HOST}/index.php

In the past, I have always hard coded in the domain. However, in this case, I have multiple domains pointing to the same .htaccess, so will need the .htaccess to detect the appropriate domain.

Using the above .htaccess code, my page redirects to… “http://%{http_host}/index.php”

What’s the correct way to use %{HTTP_HOST}?

Please let me know if you need any clarification. Thanks!

Dave

ErrorDocument is not a part of mod_rewrite, so you can’t use mod_rewrite’s variables in it.
Can’t you use


ErrorDocument 404 /index.php

?

That won’t redirect to the home page, but it will show the homepage.

BTW. I personally find showing the home page on a 404 a bad idea. If I come to your website from google and the page I wanted to visit is no longer there but I get to your homepage instead of a 404 page I’ll search for a few seconds to see if I can find what I was searching for, probably won’t find it, grumble, and leave your site. So you’re basically wasting my time (no offense). If you show a 404 I can respect that and get back to google instantly. Or you could offer me some options I might be interested in in the 404 to try and keep me on your site. Which is better than “baiting” me with your homepage IMO.
This is just my opinion of course, you’re free to feel otherwise.