Forum Home
Press F1
 
Thread ID: 87977 2008-03-10 22:43:00 Host file redirecting - help needed Morgenmuffel (187) Press F1
Post ID Timestamp Content User
648474 2008-03-10 22:43:00 From the German thread

This forum has 4 URLs pointing at it. You can use whichever one you prefer:
http://pressf1.co.nz/
http://www.pressf1.co.nz/
http://pressf1.pcworld.co.nz/
forums.pcworld.co.nz just happen to prefer the top one.

I would like to put a redirect in my hosts file to redirect all traffic pointed at those addresses to just one address, I know how to do this in apache, but windows is a different beastie

Anyhelp would be appreciated
Morgenmuffel (187)
648475 2008-03-10 23:02:00 Nigel,

First thing you need to do is establish what IP address http://pressf1.co.nz/ actually resolves to - you can do this by pinging that address from a command line

You then need to add entries to the hosts file on your PC located in
C:\WINDOWS\system32\drivers\etc that force the other 3 addresses to resolve to that first IP

It's possible that any anti-virus/spyware software you have may try to stop you doing this, as redirection via the hosts file is a common malware trick.

Let us know how you get on
nofam (9009)
648476 2008-03-10 23:04:00 From the German thread


I would like to put a redirect in my hosts file to redirect all traffic pointed at those addresses to just one address, I know how to do this in apache, but windows is a different beastie

Anyhelp would be appreciatedThose addresses *already* resolve to the same IP. Adding them to your hosts file will achieve absolutely nothing.
Erayd (23)
648477 2008-03-10 23:24:00 My issue is that i often follow a link someone has posted to another thread and if they dont have the same base url as i do i have to login to that particular version of the forum - make any sense Morgenmuffel (187)
648478 2008-03-10 23:29:00 My issue is that i often follow a link someone has posted to another thread and if they dont have the same base url as i do i have to login to that particular version of the forum - make any sense

Makes no sense at all.
Don't complicate your life and your computer.
Take everything out of your hosts file, I never use it and never have any problems with links.
Safari (3993)
648479 2008-03-10 23:40:00 My issue is that i often follow a link someone has posted to another thread and if they dont have the same base url as i do i have to login to that particular version of the forum - make any senseYep, that makes sense. The solution is to point three of the URLs at 127.0.0.1, run a webserver on your PC, and put a redirect script there that sends the browser to the correct location. It works, but it's not pretty.

A better solution would simply be to allow cookies from all 4 domains, and tell it to remember your login. That way you're logged in by default, no matter which domain the link you just clicked uses.
Erayd (23)
648480 2008-03-11 00:12:00 I'm not sure what you could achieve by tweaking your local hosts file to resolve all Pressf1 domains to the same one. I do however think it would nice on PressF1's part to tweak their htaccess file to do this as you are right, it could be a little confusing if someone follows an internal link and not realising that switching domains means you aren't "logged in" anymore, even though you're on the same site.

I'm sure a little mod_rewrite action would be beneficial, even though the search engines seem to be putting a lot of loving their way despite this. Oh wow, what's that down there.


#Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.pressf1.co.nz [NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]

RewriteCond %{HTTP_HOST} ^pressf1.pcworld.co.nz[NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]

RewriteCond %{HTTP_HOST} ^forums.pcworld.co.nz[NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]

This solution is retroactive so old links won't break and will still get to the same page which is what is expected I suppose.
sal (67)
648481 2008-03-11 00:42:00 A better solution would simply be to allow cookies from all 4 domains, and tell it to remember your login. That way you're logged in by default, no matter which domain the link you just clicked uses.

I do that currently, but as I dualboot plus have a laptop and often work off my wifes machine (and ocasionally use multiple browsers), I often find myself going to an unlogged in variant depending on which machine i am on, it's not a biggie but it is an avoidable nuisance, although googlebrowsersync does make this a bit easier


I'm not sure what you could achieve by tweaking your local hosts file to resolve all Pressf1 domains to the same one. I do however think it would nice on PressF1's part to tweak their htaccess file to do this as you are right, it could be a little confusing if someone follows an internal link and not realising that switching domains means you aren't "logged in" anymore, even though you're on the same site.

I'm sure a little mod_rewrite action would be beneficial, even though the search engines seem to be putting a lot of loving their way despite this. Oh wow, what's that down there.


#Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.pressf1.co.nz [NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]

RewriteCond %{HTTP_HOST} ^pressf1.pcworld.co.nz[NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]

RewriteCond %{HTTP_HOST} ^forums.pcworld.co.nz[NC]
RewriteRule ^(.*)$ pressf1.co.nz [L,R=301]This solution is retroactive so old links won't break and will still get to the same page which is what is expected I suppose.

I suggested something like that a while back (pressf1.pcworld.co.nz), I use a very similar script to the one above on some of the sites I look after, it just cuts down on the confusion

Is Scott Bartley still around? perhaps we should give him a prod and see if he prods the web person
Morgenmuffel (187)
648482 2008-03-11 01:09:00 I had wondered why I got "not logged in" on a number of occasions following another post link - now I see.





Is Scott Bartley still around? perhaps we should give him a prod and see if he prods the web person

He was 6 days ago...


View Profile: Scott Bartley - Last Activity: 05-03-2008 12:06 PM


Doesn't seem like he followed thru on this tho (6 months ago)


Stop talking such sense. You'll draw attention to yourself round these parts...

:)

I'll bring this to the attention of our web person and see if they blink blankly back at me.
bevy121 (117)
648483 2008-03-11 20:17:00 Hello Nigel,

for firefox is a addon called Redirector (addons.mozilla.org) availabel.
Mylin (13483)
1 2 3