Barba.js - Update URL if a PHP redirect has occured - redirect

I've got some dead pages in my site that I just need to redirect.
Thing is, if you click on a link where it goes to one of these redirected pages, the redirection will occur, but the URL will be kept as the old, dead page.
Example: I click on a page /a/ that PHP redirects to /b/. The redirection happens, /b/ is shown, but the URL stays /a/ until I would hard refresh (CTRL+R) the page.
So is there a way to make it so Barba follows PHP redirects and updates the URL to show the right one?

Related

How do I cancel GitHub Pages redirection?

I created a web page using GitHub Pages. I added the custom domain by following the Settings>Pages path. The page redirect was successfully performed by creating the CNAME file.
I wanted to cancel the page redirect after a while. Therefore I removed the CNAME file and followed all the steps mentioned in the documents. But I was not able to cancel the page redirect. How can I fix this problem?
Since the website redirect is saved in the browser's cache, the redirect will continue even if the redirect is cancelled via the Settings>Pages tab on GitHub; this will automatically cause the CNAME file to be deleted. The way to solve this problem:
Remove the previous redirect by going to Settings>Pages on GitHub.
Rebuild the page via the Actions tab on GitHub.
Click the F12 while the browser is open.
Long click on the refresh button on the browser.
Select the Empty Cache and Hard Reload option.
When you try to enter the website again, you will see that the redirect has been cancelled.

How can I dynamically set a site's referer in Chrome?

I'm not sure how to make this question reproducible because it requires having a Vimeo paid (or on a free trial) account.
Vimeo recently changed their UI for creators and made it harder to access one of the pages I use every day.
From https://vimeo.com/manage/videos there is a table with links to individual videos. The URL for each link is something like https://vimeo.com/55555555555555/settings.
If you click, it sends you to Page A: https://vimeo.com/manage/videos/55555555555555.
Then, there's a button that sends you to the page I actually need (Page B): https://vimeo.com/manage/55555555555555/general.
The problem is that when I enter the URL for Page B directly in my browser, it redirects me back to Page A.
Strangely, the back/forward buttons navigate between pages A and B, and the refresh button also stays in Page B. But if I copy Page B's URL, open a new tab and paste it, it sends me back to Page A.
To figure out what's going on, I looked in the network tab of the Chrome Developer tools and found that the first request from Page A to page B looks like this:
But then, if I paste that URL in a different tab, I get a 302:
I've diffed both requests:
Is there a way to prevent the 302 behavior?
I don't have a vimeo account and thus can not test it. Ultimately, the server could use any parts of the diff, but I'd expect it to use the referrer.
Does the page always direct you back if you completely disable setting the referrer in Chrome? If so, using a plugin to forge your referrer could solve the issue.
Unlike 301 redirects which are permanent, 302 are not. The web server displaying 302 errors should redirect the browser and take you to the new location immediately. It should be noted that HTTP 302 status code is due to the web server and not the web browser. There is no control at your end.

Perl WWW::Mechanize and pages that redirect automatically after a countdown

I have a script that can log into a webpage when it finds a login/sign-in form on a webpage. Everything works perfectly, even if the page is a redirect as it finds the Location element in the http header and follows it and so on..
However, the issue I am having relates to websites that display a page first with a message saying "You will be automatically redirected in 5 seconds", (or something similar) and then redirects you to the page after the 5 second countdown.
What is happening:
Mechanize is GETting the URL.
It reaches the page that says "You will be automatically redirected in 5 seconds", but because this page has loaded properly and is just a normal page with a 200 status (rather than a redirect status as the redirect only occurs after 5 seconds), it thinks that there is no redirect on this page so it will look for a login form and try and login.
But obviously a login form doesn't exist because it is just the small page you see briefly before the redirect actually occurs.
Does Mechanize have the capacity to deal with instances such as this and if so how?
The only way I can see possible is by following the redirect link that is usually provided for users to click if the page doesn't automatically redirect itself.

Facebook does not show authentication when running under canvas

I have a web site already integrated with Facebook login, using server-side authentication.
I have an issue to turn it into an application running under Facebook.
The problem is that Facebook does not show the authentication page at all
Therefore, I am not even getting to the server authentication process for real.
Right now, the application is running on my local machine.
My app is defined as Facebook Application: (adding blank before localhost for site security purpose only)
Canvas URL: http ://localhost:4300/fbopt/
Secure canvas URL: https ://localhost:4303/fbopt/"
[same problem happens when running in a Sandbox, without Secure URL]
I have a "fan page" with "Go to App" button there.
Pressing a button leads me to the URL:
https://apps.facebook.com/[appid]/?fb_source=timeline
The browser starts loading the page with the frames.
The lower frames makes the POST request to the URL I provided.
My application redirects the page to the following URL:
https://www.facebook.com/dialog/oauth?client_id=[appid]&redirect_uri=https://localhost:4303/fbopt/hook&scope=email,user_location,user_birthday
I would expect Facebook to show up the application authentication form, with the permissions required.
Unfortunately, this does not happen. An empty page is shown within the frame, HTML is empty!
I see (from the Chrome network debugger) that the URL is indeed accessed, but the response is with HTTP 200 status (not error), but no response data. Instead, getting
X-Frame-Options: DENY
response header - rendering denied within frame! Why?
When loading the URL above "manually" outside the Facebook frames structure, I do get the authentication screen with the right permissions.
I wonder what is missing to get it work with canvas.
Any hint on what I should add, or how to debug such a problem - will be appreciated.
Thanks ,
Max
Looks like me fundamental problem was that I was trying to redirect the whole page, instead of making a frame redirection.
Started here:
Blank Canvas => 'Refused to display document because display forbidden by X-Frame-Options.'
Went here:
https://developers.facebook.com/docs/howtos/login/login-for-canvas/
It says:
Because your application is being loaded in an iframe, returning a 302 to redirect the user to the Login Dialog will be unsuccessful. Instead you must redirect by setting the Javascript window.top.location property, which causes the parent window to redirect to the Login Dialog URL
This was probably my major mistake.
Max
Do you have iframe in your app? Sending X-Frame-Options with content DENY is Facebook's way to fight with clickjacking. More info:
http://darklaunch.com/2010/11/09/facebook-s-anti-clickjacking-techniques
adding an iframe to facebook does not work anymore since ~2 weeks
I've had the same issue. 302 Redirect works because I use a lot of those but you cannot redirect to a facebook domain for any reason. If you want you can do a top redirect via javascript. What I did is I created an html that accepts a url and it loads it in top.location then redirects back to apps.facebook.com. With X-frame most probably because you have a AntiForgeryToken (if using .net) because this would insert xframe sameorigin in the header. You can disable this with
AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

How to do popup on new site for 301 redirected users?

I have just migrated a site to a new domain (with new design) and am redirecting from the old site to the new with .htaccess and redirect 301. Since the new site is quite different, I'm concerned that users might be disoriented. Is there a way to have a popup on the new site that users get only if they have been redirected from the old site? Have been searching on this but keywords seem to lead only to stuff on popup redirects to another site.
I can think of several ways to do it:
Redirect in the 301 to another page (www.blah.com/tour instead of www.blah.com) and there i would put the logic to show the popup
Redirect in the 301 to another page and there set a cookie and redirect to the original page. Then, add logic to the original page to show the popup if the cookie is present (and delete the cookie)
Check the referrer in the new site and if it matches the old one, show the popup
Your problem boils down to detecting a request that has come via a 301 redirect - popups and usability are a separate (simpler?!) issue.
Unfortunately, detecting a 301 redirect is one of those inexact things that requires a mixture of techniques to get near to 100%. I say near, but never quite there - a bit like browser detection.
One option is to append a querystring (GET) parameter to the redirected URL, e.g.
www.example.com/LandingPage.html?isRedirected=true
You could also set the same info in a cookie (but won't work if cookies are disabled or cleared).
Another option is checking the Referrer header - but again, these may differ based on browser implementation and can be faked, although if someone's faking a redirect I don't think you need to worry about guiding them through your new design!