Is it possible to get a reference to the vanity URL used after redirection? - aem

I have a page http://localhost:4502/content/project/en/mypage.html and it has couple of vanity URLs set as
/content/project/vanity-1
/content/project/vanity-2
So any request from the above two vanity URLs are being redirected to /mypage.html.
Is it possible to get the vanity URL request from where the page is redirected to? i.e how can I find from which vanity URL the request is coming from?
request.getRequestURL() gives me ../mypage.html but I need to get the vanity URL request.

You should try to get it from /content/project/page/jcr:content properties sling:vanityPath

It's available in the HTTP referer header. You can get it as follows:
String referrer = request.getHeader("referer");

Related

Do 302 HTTP responses remove parameters appended to the original URL?

When a client browser receives a 302 response, does the browser modify or ignore any parameters appended to the end of the URL?
For example, I have a server that redirects requests to a different URL but retains any parameters from the original URL and appends to the end of the new redirect URL. However, browser is not including the parameters in the new URL.
For example, if a request comes in to "https://server1.com/path1?filter=value", the redirect server responds with a 302 and "location: https://server2.com/path2?filter=value". But, issue is that the client browser seems to only recognize "https://server2.com/path2".
Should parameter values be tagged a different way in the response?
As noted by Remy Lebeau in the comments to the question, the browser does not modify the location URL in the 302 response. Rather, the issue was caused by the networking in AWS - I was using AWS Lambda to perform the re-direct by reading in the URL on the original request coming in and re-directing according to mapping in the function. First issue was that API gateway was stripping off the query parameters before it was hitting the Lambda function. Second issue was that the function read the "rawPath" attribute from the request, but this does not contain URL query parameters; the query parameters are contained in the "rawQueryString" attribute instead.

Redirect haproxy from url to another keeping this same path/uri

I want to redirect as the below examples, keep the same path/uri but change the url.
https://test1.com/example1/example2 --> https://test2.com/example1/example2
I managed to do it for the url only by creating an acl acl_name base url and then do a redirect code 301 with an if conidtion.
Thanks,

Facebook privacy policy URL: Bad Response Code: URL returned a bad HTTP response code

I want to publish my first Facebook application and a Privacy Policy URL is required.
I have the page privacypolicy.html published in my website but I get the next message when I configure it in "App Details":
You must submit a valid Privacy Policy URL in order to be compliant with Facebook Platform. Request failed with error:
Bad Response Code: URL returned a bad HTTP response code.
The http code returned when I request the page is 200
Any ideas?
The URL is cached by facebook.
Adding # at the end of my Url did the job ..
This is an old question I know, but I figured I'd post my solution and hope it helps anyone. For me I got this error because I had rewrite rules that didn't catch the URL that Facebook actually goes to in order to get the privacy policy. Facebook adds a query string to the URL that you give it for the privacy policy and since my privacy policy page doesn't do anything with the query string, I didn't check for it in my rewrite rule.
You can check out how Facebook scrapes the page you give it by going to Facebook's Sharing Debugger and putting your URL in the input bar. You can also see the last time that Facebook tried to scrape that URL and tell Facebook to try again once you've fixed any issues. This will get around the caching that was mentioned in user2390340's post.
Facebook externalhit appears to request via the ipv6 address published in DNS if there is one available and won't check on the ipv4 published in DNS.
If your website doesn't have ipv6 enabled it'll return a 404 or 500 and you'll get that error "Bad Response Code: URL returned a bad HTTP response code" for your Privacy Policy URL.
Edit:
Also noted that Facebook caches the URL, I was checking it and getting a "bad response code" error even though there was no hit from their UA in the access logs.
Adding ?stuff onto the end of the URL in the Privacy Policy field bypassed a cache and the access log hits showed up with 200 OK, allowing the URL to be saved.
Not sure if this is related to user2259887's comment about Facebook using IPV6 DNS. But after reading his comment, I was able to work around the validation issue by specifying an IP Address URL instead of using the host domain name URL.
This workaround will not work well if the site IP address is dynamic or change often.

url requested redirect but the

When I pass the url by the Facebook debugger I receive the "Critical error"
"URL requested a HTTP redirect, but it could not be followed."
The redirected URL is the same as the Fetched and Canonical with the added "?AspxAutoDetectCookieSupport=1". So the link rejects this .
I tried the cookieless = UseCookies at Web.config in order to avoid the cookiesupport parameter in the URL but nothing happens , is still there.
this is the section in web.config :
<sessionState cookieless="UseCookies"/>
Is this fine?
Another way for suppressing the parameter?
Its a Facebook cache issue?
You can try it :
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fdisaweb.com%2FModulos%2Ftorre-noria-11.aspx
Thanks in Advance
You're link redirects to:
http://disaweb.com/modulos/torre-noria-11.aspx/?AspxAutoDetectCookieSupport=1
but that returns a 302 to the same location. You can't return a 301 or a 302 to the exact same location that is requested.

Not getting $_REQUEST['signed_request']

I'm trying to pass some variables to my facebook app from the url, i.e. using GET variable app_data like facebook wants.
At some point I've stopped getting the ['signed_request'] part of the $_REQUEST. When I print_r($_REQUEST) I'm getting: ['doc'], ['user'], ['__utmz'], ['__utma'] and ['session'] values, but not signed request :(
Any ideas of why this might be happening?
Check the tab/canvas url is EXACTLY the same as required. If there is a redirect to another page, then signed request and other values will not be sent. You can check using a browser sniffer, if a call to the page responds with a 300 (301/302 etc) redirect, then you need to change to what it redirects to.
Examples:
https://example.com/ may need to be https://www.example.com/ (add www., or remove www. depending on how server is set up)
www.example.com/ may need to be www.example.com/index.php (add index.php, or the right page).
Check you are using http:// and https:// correctly in the URLs, and that https:// returns a valid page.
I've only been able to get the signed request in https://, i get no request at all in http.
Currently have a bug on FB, but no word on fixing it yet; http://developers.facebook.com/bugs/264505123580318?browse=search_4eb3ef23eb18d6649415729
EDIT:
http://SITE.com was redirecting to http://www.SITE.com, so I was loosing the request variables.
Had a similar issue, for me it was as simple as a mismatch of the app id and app secret! However in facebook developers backend I have noticed that the URLs all need to have that trailing slash!
Some browsers do redirect your request to https automatically if you have been on this particular site on https so if you are in http mode on facebook there is situation:
facebook requests http version of your app, browser redirect this request of facebook to https and POST data and thus signer_request are gone in this process...
i see this problem in chrome 23, if you delete browsin data (particulary Deauthorize content licenses) app should run back on http