Redirect due to browser? - browser

I am wondering if there is a way to redirect users using a specific browser to a different page?

<!--[if IE]>
<script> window.location='http://getfirefox.com'; </script>
<![endif]-->

First you could use JavaScript to detect the browser, and then you could set the window.location variable for the redirect.

Related

Setting custom referer in Express app before redirecting

I am working on this simple app which requires me to set custom referer value before redirecting.
Suppose A clicks on link X which I posted in Facebook. Now if I check the referer value in my server, then it shows 'facebook.com'. Now A after clicking link X is being redirected to B and B shows referer 'facebook.com'. But I want it to show 'mywebsite.com' in B instead of 'facebook.com'. How can I achieve this?
Please note that I read in MDN about the 'Forbidden Header Names' but there's this website called Hitleap which is a traffic exchange website. They let users set custom referer values for the traffic they send. So I guess it's possible to do it.
This is my route:
router.get('/:id', (req, res) => {
res.set('Referer', 'https://mywebsite.com');
res.redirect('https://boomboom.com');
});
UPDATE
I've found that it's not possible in conventional methods of setting the header. So, I have been thinking of achieving this result by using the following two methods but I don't know if that is going to work. So looking for feedbacks.
Method 1:
So when a user clicks on my link, he will visit a page on my server before redirecting to the final destination. The page on my server will just say "redirecting". And when that happens I will also set the full header for the user, including "Referer" field. Then redirect to the actual page.
Method 2:
Same approach as method 1 but this time I would like to copy the full header from the client but change the referer value when the user is in my "redirecting" page and the redirect to the final destination.
Are any of these processes possible? If you have any other solution please share it here. Thanks
Referer headers in the HTTP protocol go from browser to server, not the other direction. If your server sends one to a browser, the browser ignores it.
Standard commercial browsers make it hard to mess around with the value of the Referer header from browser Javascript. Because cybercreeps. Your plan might be perceived by some websites as an attempt to do a cross-site request forgery attack. So think through your goal carefully.
You could, from your site, serve a page that causes your user's browser immediately to redirect to the desired site. A page something like this may do the trick for you. This means refresh the current page after 0 seconds from the URL https://example.com.
The title tag sets the browser-tab caption to "Redirecting..." while the refresh is in progress. I've found that useful in single-signon redirection. It lets a user know something is coming.
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=https://example.com/">
<title>Redirecting...</title>
</head>
</html>
If that doesn't set the correct Referer, which it might not in all browsers, you can use a little bit of Javascript to load an invisible form and then submit it immediately.
This tiny page might do it for you:
<html>
<head>
<title>Redirecting...</title>
</head>
<body>
<form method="GET" action="https://example.com/">
</form>
<script>
window.onload = function(){{
document.forms[0].submit()
}}
</script>
</body>
</html>
This second approach won't work if your user disables browser Javascript. But, then again, most websites won't work in that case.
You can troubleshoot all this with your browser devtools Network tab. It shows headers for each request.

Have a domain bring up a page hosted on another domain

I need a domain--without hosting--to bring up content from another server. I.e. I have access to the domain's DNS, but nothing else.
How do I make a page--hosted on my server--load when my clients' URL shows up?
To clarify, I want a visitor:
To type sl.wellnessandyourself.com
For the page www.ceramiclion.com/drops/index.html to show up
For sl.wellnessandyourself.com to still be the url in the user's browser.
I've heard mixed comments on this. Websites like Weebly are able to do this. How can I do this as well?
EDITED:
See the above comment about CNAME as a far better solution than what I just offered.
I am not fully certain, but I think the only way to really do this is to use an IFRAME tag embedded in your own page code:
<html>
<head>
<title>IFRAME Example</title>
</head>
<body>
<iframe style="min-width: 100%; min-height: 100%; outline: none;" src="http://www.ceramiclion.com/drops/index.html" />
</body>
</html>
This sort of hearkens back to the good ole days of frames in HTML. Ahh, memories.
Why not use a CNAME? This is pretty much what it's used for. All you need is to edit the DNS records for the domain name. Obviously, you have to have access to these, but, it's pretty simple to do. No hosting required on your end.
You'll set up the CNAME for sl.wellnessandyourself.com to be www.ceramiclion.com/drops, and it should work how you want it.
Here is more information:
https://serverfault.com/questions/65712/using-cname-to-point-to-another-domain-to-save-ip-addresses
https://support.dnsimple.com/articles/cname-record/

How can I show a picture before a link in google sites

I have a website that i've set up through google sites. I have a link to an external webpage. What I'd really like to have happen is, if someone clicks the link, it shows a jpg picture for about 5 seconds and then forwards them off to the linked website. Is there a way to do that?
Thanks,
Rich
Adding to following tag:
<META http-equiv="refresh" content="5;URL=http://example.com">
to the <head> section of a webpage will redirect the user to example.com, or whatever the URL value is. You can display an image in the <body> section of this page. This seems like the simplest way to accomplish what you want.

Security check to avoid direct visitor on a page

I have a page that I want to be loaded only from an iFrame.
I use the solution on this link to do it.
How to identify if a webpage is being loaded inside an iframe or directly into the browser window?
but it doesn't work in IE so I use conditional comments like this
<!--[if IE 9]>
<script type="text/javascript">
window.location = "http://mysite.com/nodirectvisit.html";
</script>
<![endif]-->
Together they are now working in IE, Chrome, FF, and Opera.
I just want to ask if there are still other ways to visit my page directly?
Thanks
If a user disables javascript, then your code will not run. Maybe use Sessions to track from where users are coming from?
Anyone with javascript disabled or NoScript would be able to open the page directly. The javascript should prevent the majority of users.
You can check the referrer of the iframe page to make sure it's the page that contains the iframe. The referrer isn't the most reliable field, but if you're more worried about people visiting the page not in an iframe than people not being able to see it at all, that might be the way to go.

htaccess problem

i have to write htaccess for mysite. actually we have two domains. '.com and .in' . for example i opened '.com' site it will actomatically access files from '.in' domain. there is no files in .com site. how to write .htaccess for this.
thanks.
If you have access to the web server, use the configuration to archieve this. In case of apache2, it would just require a server alias in the virtual host. Otherwise, use redirects or url rewriting.
If you cannot use them either (because you are on a limited virtual environment, f.e.), place an index.html in your .com directory, configure it to redirect via meta-refresh tag. Place the following line in the header section of your index.html:
<meta http-equiv="refresh" content="0; URL=http://yourinsite.in/">
Then use the DirectoryIndex directive on a .htaccess file to automatically load it as default index page:
DirectoryIndex index.html
This brings up the index.html when the user browses yoursite.com/ and lead her to yourinsite.in automatically.
Do you have access to the server config? Judging by your comment above what you actually want is to setup a server alias, where the .com and .in sites are the same? This will make the .com site load the .in or vice versa.
Another solution you could use if you don't have server access it use a domain frame cloak, which will keep the .com URL in the address bar but load the .in site inside a frame, put this code in index.html on the .com site, fill in what toy need to.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>TITLE OF THE SITE</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="Description" content="Description of the site"
</head>
<frameset rows="100%,*">
<frame frameborder="0" src="http://domain.in" scrolling="auto">
<noframes>
<body>
<p><b>Welcome on our site. Your browser do not support frames.</b></p>
<p>Click here to go to the page.</p>
</body>
</noframes>
</frameset>
</html>

Resources