Forum Moderators: phranque

Message Too Old, No Replies

Redirect 302 / hosts

         

kalle

12:12 pm on Apr 13, 2004 (gmt 0)

10+ Year Member



Hi,

I've got this problem:

When someone write example www.test.dk in their hosts file on Windows and use our IP they can show our website of course.

Can I do so that if anybody ask for a domainname on our server and it's not one of ours, they will be redirected 302 to example www.test2.dk?

kalle

jdMorgan

3:13 pm on Apr 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kalle,

Welcome to WebmasterWorld [webmasterworld.com]!

See the code in the first post of this thread: [webmasterworld.com...]

Simply omit the first line of code, and change the last line so that it says R=302 instead of R=301.

Also, you'll need to add a space preceding the "!" the code - posting on this forum removes them.

Ref: Introduction to mod_rewrite [webmasterworld.com]

Jim

kalle

12:43 pm on Apr 14, 2004 (gmt 0)

10+ Year Member



Hello Jim,

Thanks - the code below makes it work:-)

RewriteCond %{HTTP_HOST} !^www\.test\.dk
RewriteRule (.*) [test.dk...] [R=302,L]