22

When I type in a URL and hit enter, for example abc.com, I don't expect to end up somewhere else. I expect an error page if there isn't a site with that URL. But instead I get redirected to another URL (another domain even: abc.go.com).

I'm no expert on web technology, but as far I can tell there are two main categories of redirect, DNS/registrar redirects (invisible) and server side redirects (visible, http code 301 or 302).

How do I prevent these server side redirects in Chrome? Best case scenario I get a prompt page telling me the page has a different URL or IP, asking if I want to continue.

Another example is hackoverflow.com I get redirected to two sites from here, after the first redirect I can glimpse a designed homepage before being moved on to a parking site. I'd like to stop halfway this double redirect and examine the second site.

11
14

I realize this is far from a perfect answer, as this will only work for responses that serve up content, but I decided to post it as there are currently zero useful, actionable answers.

As a quick-and-dirty solution you may be able to use the debugger (accessible by F12 or CTRL+SHIFT+I in most browsers) to give your self an opportunity to opt out of a redirect.

Run this line in the console before the page runs any scripts of its own:

window.onbeforeunload = function(){ return 'Leave page?'; };

For example, using Chrome:

  • Open the debugger (F12) and switch to the Sources tab.
  • Press F8 to put the debugger into step-through mode.
  • Navigate to the problematic page. It will begin to load but the debugger won't allow scripts to run.
  • Paste the above code into the console and hit enter.
  • Press F8 again to allow scripts to run and let the page finish loading.
  • Now you will see a prompt before any redirect occurs and you'll have an opportunity to cancel it.
  • If the page repeatedly tries to redirect you, you can tell chrome not to display the dialog again. Further attempts by the page to navigate you elsewhere will fail silently.

Prompt restores user control

2
  • Doesn't not work, pause is cancelled when loading the problematic page – hymced Sep 5 '20 at 12:41
  • It certainly won't work in all circumstances and may not necessarily work on all browsers. – snarf Sep 6 '20 at 14:27
1

As far as I know, there is no way to disable this function.

More importantly, doing so would break a very basic functionality that Web Servers rely on. You can expect a lot of websites to just stop working.

At bare minimum, - all 'www' redirects would stop working - all 'http-to-https' redirects would stop working

So you would manually have to type in 'https://www' before every domains.

Beyond that, many subpages within websites would stop functioning as well.

So I would not be surprised if Chrome and Firefox developers make it very difficult or impossible to disable Redirects altogether at the browser level.

4
  • So this security risk is actually a web feature? – jiggunjer May 7 '20 at 5:57
  • 1
    Absolutely. It is built into HTTP protocol. A redirect is a server response 301 or 302. – madacoda May 7 '20 at 7:04
  • 1
    This is somewhat like saying adblockers don't make sense and would break the web. Wanting to prevent redirects when they have harmful or counter-productive effects shouldn't be a non-starter. OP described a scenario where a page loads before the browser is redirected. This is a scenario I've run into many times. Regardless of the response code, if there is a page served, I would like to have the option of viewing that page. – snarf May 31 '20 at 17:41
  • 5
    It would also be useful for developers trying to debug redirect problems. – David Moles Nov 9 '20 at 23:37
-1

Using the Dev Tools, there is a tab that will display all the assets initialized by a page and their source as a URL (Networking? Sources?); even easier, after closing a popup, go to your history and see the URL there.. Either way, if you know the server address ("popup.ads.com" etc) Then why not make an edit to your HOSTs file (Linux/Win/Mac compatible) and just not run the risk of having a sketchy site read/write cookies, and potentially try to hijack your browser?

All that you'd need to do is add a line for each domain to block such as:

0.0.0.0 ads.com Or 0.0.0.0 popup.ads.com (Sub domains can be blocked while leaving the parent domain unblocked)

2
  • 1
    I fail to see how this answers the question. – jiggunjer Apr 14 at 5:30
  • Seems I misunderstood the intent. @snarf takes a similar approach and addresses the intent to stop the redirect (without just routing the request to null). I had read the OP as though you were trying to blacklist the site(s) affected--as opposed to just preventing the redirect(s) – JoeBro May 7 at 16:50
-4
  • Open Google Chrome.
  • Update Google Chrome.
  • Click ⋮.
  • Click Settings.
  • Scroll down and click Advanced ▼.
  • Scroll right down to the "Privacy and security" segment.
  • Click the grey "Protect you and your device from risky sites" switch.
  • Use an extension.
1
  • I'm not sure why so many downvotes. It's a reasonable option, and is a better response than some. I'm not going to upvote it though, because it's short on reasons. – Auspex Jun 1 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.