Efficent url redirection in php - php

I am using a url redirection technique similar to google
Example
if you type wikipedia in google you get a wikpedia page result but if you click the link it will first go to this kind of redirecting link
http://www.google.com/url?some_paramaeters_for_wikipedia_page_redirection
and then it will go to
http://www.wikipedia.org/
i have made similar algorithm in my website and its working properly;But as in google when you want to copy the link location
it doesnt copy the main web link
http://www.wikipedia.org/
Instead it copies
http://www.google.com/url?some_paramaeters_for_wikipedia_page_redirection
I want to know if it is possible for users to copy the orginal link instead of url redirecting link without changing redirecting method.
Thanks for your info

Yes, what you should do is keep the real link in the href attribute (so the "Copy link location" works),
and with a bit of Javascript, on the click event of your link, replace this real URL with your redirecting one's.

Related

Redirect to home url but remember first url

I am making a website for a client of mine, and it is quite complicated. It consists of a sidescrolling parallax style story and the pages are filled with a lightbox system. So when you click a link it wont go to another page but opens it in the lightbox.
Here comes the problem:
It works when you go to www.foo.com. But I want when you go to www.foo.com/subpage, it redirects to the homepage and opens the selected subpage in the lightbox. I have the code to open the lightbox from a variable. But I dont know how to fetch the url you typed.
Try getting
$_SERVER['HTTP_REFERER']
via php.
should be the URL you came from.

Activate external href onclick from link

Let's say you have a link on your site and when you click that link it brings you to a different site. A site that you do not own and I would like it to have a "onclick" already activated maybe from a script that redirects to that link. Is this possible?
Simple answer NO. If possible it would be called 'mousejacking' :)
Setting window.location.href to a target link URL in javascript will, for most browsers, redirect the browser to the specified URL.
If you're specifically trying to make a link on your site redirect the user to a Google Search, read here.
There is almost no good reason to wrap an external site that you do not own in a frame. That kind of stuff is usually considered shady/malicious.

How to make an Instant Shorten link for a url shortener

I have recently made a url shortener and I want to make an "Instant Shorten" Bookmark link on my site, like YOURLS can, so you bookmark the link, then go to any webpage, then you click on the bookmark and it automatically shortens the address, adds it to the database and tells you the shortened url in a pop-up.
I'm not sure how to do this, please help me!
Edit: This is the code that YOURLS currently uses to shorten using the bookmark link:
javascript:(function()%7Bvar%20d=document,s=d.createElement('script');window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='http://nix-pix.co.uk/public/admin/index.php?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));%7D)();
Usually a bookmarklet something like this is used:
javascript:u=encodeURIComponent(location.href);s='http://urlshortener.com/shorten.php?url='+u;window.open(s,'shortened','location=no,width=400,height=300');
That takes the URL of the current page and opens a new window pointing to urlshortener.com/shorten.php?url=[the url to be shortened]. The code used by YOURLS is more complicated, but probably does approximately the same thing. You just need to change the URL that the new window opens to in the code above.

facebook, how to get to a application page?

i've setup a application that has a path to:
www.some_page.com/index.php
on the page i have a link that goes to:
www.some_page.com/picture.php?number=123
this page displays in the same fb iframe application.
My question is how to get to www.some_page.com/picture.php?number=123 from an outside link?
if i just link to it it will take me to the page but outside the facebook app, and i need t to take me to that page inside the app..
i guess that when i click on that link i have to send the user first to accept the app access then got o that page ?!
any ideas?
Thanks
edit 1:
** what i want is to place a link to www.some_page.com/picture.php?number=123 on another site and redirect me that page inside the facebook app
There are 2 options to set a facebook app:
embed your www.some_page.com inside an iframe (this will make sure all your links will stay inside)
Follow this: http://developers.facebook.com/docs/appsonfacebook/tutorial/ and make sure you don't have target="_blank" this is a better option and your links should open in the same scope.

Get Current Page URL From Bookmark on toolbar using PHP

I am looking to get the url of current page in url bar
[BookMark Button In Tool Bar] - User Presses it while on a youtube link
and sends it to sitename.com/test.php
The url in the bookmark then prints something like
sitename.com/test.php?url=http://www.youtbe.com/whateverwatever
I tried using referrer bur since it's coming from a bookmark link it won't work
I also tried the referrer in Javascript but it still won't work
I believe you just want window.location.href. That'll get the current location then you can do what you want with it.
You can't do this, as there isn't a referrer if you click a bookmark.
If you're trying to make a "share this" bookmark sort of thing, you can use some JavaScript to make a "bookmarklet". Delicious has a bookmarklet that does this sort of thing.

Categories