Forum Moderators: phranque

Message Too Old, No Replies

301 - .htaccess (Apache) - 404 error

         

girish

2:07 pm on Mar 30, 2004 (gmt 0)

10+ Year Member



in
[webmasterworld.com...]

Jim recommends putting the following code in an .htaccess file in the root directory of the "redirecting" site to accomplish 301 redirect to the "target site"-

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.targetsite\.com
# enter target site IP address in next line
RewriteCond %{HTTP_HOST}!^123\.456\.789\.789
RewriteRule ^(.*)$ [targetsite.com...] [R=permanent,L]

When I put this .htaccess file in the root directory of my "redirecting" site if the requested page or file is not in that directory or subdirectory, I still get a 404 error.

Does anyone have a fix?

Should I set up a 404 redirect?

jdMorgan

6:46 pm on Apr 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



girish,

Welcome to WebmasterWorld [webmasterworld.com]!

It's not clear what you intend to accomplish with this code, but its intent is to redirect multiple domains hosted in one account to a single 'preferred' domain hosted in that same account.

If a page within any of those domains does not exist, you will get a 404 error, and the posted code will not change that behaviour. If you want to do something special with missing pages, then you can declare an ErrorDocument for 404 errors, or use mod_rewrite itself to detect missing pages if you need special error handling depending on the requested domain.

Jim