Safari will not redirect to querystring URL - php

I have a site built with PHP that does a redirect after certain actions are performed.
header("Location: http://example.com/accountArea/?v=updated");
I then show a message based on the value of the query string value. In safari (and only in Safari) after the redirect, you will only see a blank page. I have tried using absolute URL and relative URL in my redirect, neither work.
I was unable to find a solution by searching the web so I hope someone here is familiar with this.

What do you see in Safari's location bar? What do you see when you view source of the blank page? What happens if you go to the URL directly by typing it in to the address bar rather than being redirected? Does any error message show up in apache's error_log?

Related

How to change the domain of url that the browser is showing in download page

I have a script which used to download files from my website, On downloading page of browser, it shows the url of sender. Like
If file is downloading from http://localhost/w/download.zip it shows the same url, But what I want to give is some fake domain or url, like http://www.example.com/download.zip.
Means I want to change the url or domain that the browser is reporting the download is from.
I know it can be done by this also
Download!
But it does not change the domain. And shows me another link from that my domain.
Question is : How do I do that?
If you want to show a different URL to the user when he hovers the mouse over, you could use JavaScript for it, Google itself does something similar. Here's a simple example:
Google?
The browser will show google.com when hovering over the link, but when clicked, JavaScript redirects to facebook.com and cancels the default behaviour.
Note that this won't work if JavaScript is disabled in the user's browser (very few cases nonetheless).
Demo: http://output.jsbin.com/pehehorune

VIEWPORT doesn't work with an URL redirected

I have a problem using meta tag viewport.
When I enter into my website through the domain name I hired (a redirection to use a more confortable URL) the viewport meta doesn't work, but if I use the original URL (really ugly and not useful at all, that's why I have a redirection) to access into my web the viewport works, look here I paste the URLs to let you try by yourself:
(HERE DOESN'T WORK) This is the redirection URL: http://padelcniinfinit.com/tag_test.php
(HERE WORKS) URL real of my WEB: http://aitor.rvfcursos.com/tag_test.php
How can be possible this? Any clue about how to fix it?
thanks guys!
The kind of redirection you are using works by embedding the destination page in a frameset, you can check this by displaying the page source or inspecting it through the developers tools of your browser. It's not an actual redirection (as in HTTP 3xx) but a page at a nice URL which embeds your ugly-URL page.
As such, the embedded page gets an invalid viewport value.
There may be some workarounds that you can use discussed in this thread.

Get destiniation URL using PHP?

I'd like to redirect the user depending on the destination url and referrer url. Say I have a homepage url http://www.example.com/ and in that page there are a bunch of links that point to http://www.example.com/page/x/. When the user goes to http://www.example.com/page/ from http://www.example.com/ it should redirect to another page. But when the user goes to http://www.example.com/page/x/ via a link from http://www.example.com/ it should not redirect. In order to achieve this, the solution I am thinking is to get the destination url as well to correctly determine if the user comes from http://www.example.com/ but wants to view http://www.example.com/page/x/. Bottom line is I want to prevent access to http://www.example.com/page/ but not to its sub pages.
What you are trying to do here is scary bad.
You can't rely on the referer being returned by the browser (but it is a good indicator). You could use a generic javascript to rewrite every link on the page to append a CGI variable containing the URIencoded URL of the current page (but where javascript is enabled it won't work). Or you could put rewrite the output buffer to inject CGI vars into hrefs in PHP. Neither of these are trivial - and if they break your users will not be able to navigate.
But leaving aside the implementation for now - your solution seems to be rather absurd.
If the problem is to
prevent access to http://www.example.com/page/
but allow requests for
http://www.example.com/page/x/
Then create an index.php in http://www.example.com/page/ with something like....
<?php
header('Location: /', true, 301);
?>
Or disable auto-index on your webserver.
As it seems no one can access the example.com/page/, You can have a Header function in the http://www.example.com/page/ to redirect the page to some other page.

Avoiding cross site scripting

AM a newbie in php, i have seen some web applications that have only index.php showing on the browsers address path, when you put the mouse pointer, you would see that the links show with together with the variables required for the next page. However when you click on the link, the address bar would still show index.php. If one enters the variables directly on the address bar, then it takes you back to the home page.
How is this done?
A common way to do this is using AJAX or JQuery, allowing you to place content from other pages within an element of your mainpage, not causing a browser page refresh, while still having the same page in the url.
Using firebug extension of firefox, on the network tab, you can inspect what is send and how to the server.
This can be done with some success by checking the HTTP Referer header.
Here is a link of how to do it
Beautiful way to remove GET-variables with PHP also checke using htaccess

URL hiding in PHP

How do I display another url or main domain name instead of filename in php? For example suppose I am redirected to file http://example.com/myfolder/test.htm, then instead of specified url I want to display example.com in the address bar for such url. How can it be done?
you can do this with .htaccess here is a useful link.
Not with PHP, you can use Frames for that, but this isnĀ“t relay a good design I think...
This can not be done in php. PHP is server side language and the request sent is from user.
So if you want user to open http://www.example.com and show http://www.example.com/folder/script.php page use URL REWRITE.
But if you want a user who have opened http://www.example.com/folder/script.php to show http://www.example.com in address bar but still show script.php content.
On accessing script.php page redirect to http://www.example.com/ and in your index page check for referrer. If its script.php (within your own domain) just include that page.
It will be a long work but it depends what you need. Its just an idea.

Categories