So I'd like to create a shortened url (similar to Bit.ly) but my own version of it. I want the URL to be a branded url such as (Goo.gl or Amz.on) I want to create this url and have it redirect to about 10 different URLs. For example: You click this shortened url (exam.ple) you get redirected to either Youtube, Google, Amazon, or Reddit and a few more pages but randomly and only those pages. How can i do this? I want this for a very specialized reason and I'm a bit stumped on how to do this. I'ts not a priority but If I could also get advice on how to create these URLS through programming my own "Generator" I would appreciate that. Thank you in advance! :)
-
1I wonder what this "*very specialized reason*' is. The only use for randomised links through a URL shortener that I can think of would be to make it more difficult for the user to know where they will end up. I can only see this benefiting ads or malware. – Obsidian Age Apr 30 '18 at 01:49
-
Possible duplicate of [Generating a random link through Javascript/HTML](https://stackoverflow.com/questions/37751759/generating-a-random-link-through-javascript-html) – Obsidian Age Apr 30 '18 at 01:51
-
@ObsidianAge Thank's for your concern. Absolutley not. I'm actually trying to do search engine ranking by advertising this url to ad platforms (Adwords) and have it redirect to google with differerent phrases of search that I would copy and paste so that my site can move up in the ranks. Ex: Making a url that redirects to 10 search urls that have my websites name so that google can bump me up. I appreciate your concern, but I'm not talented enough to make malware haha :) – Larry Apr 30 '18 at 02:04
-
While this might serve as a good exercise for your programming skills, assuming Google does not interpret Javascript is foolish, at best. Now, that you've made clear what you want to achieve, feel free to ask a programming question. What are your difficulties in writing this particular script, other than not having made any attempt whatsoever? If you need more details, do read [ask] and [What types of questions should I avoid asking?](https://stackoverflow.com/help/dont-ask). – tao Apr 30 '18 at 03:08
-
@AndreiGheorghiu Hello. Thanks for the comment. I've forgotten about the code upload however I've tried to create href redirects through html and bit.ly however I have had no luck. I was asking more as to how I would be able to do it as none of my code could do it. Thanks :) – Larry Apr 30 '18 at 03:18
1 Answers
For those who just need a URL
I was surprised something like this doesn't exist, so I made the following website:
http://autorandomredirect.com/
It lets you pass in a bunch of URLs as a query parameter embedded in the main URL, and randomly redirects you to one of them. So, for example:
http://autorandomredirect.com?urls=google.com,yahoo.com,bing.com
For the OP's very specific use case (mentioned in the comments) of randomly redirecting to one of many Google searches, it would look something like this:
Note how escaping (e.g. %2F
in place of /
) is necessary for these less-trivial URLs.
For those who want to implement something similar
There's many ways to do this. I chose to do it entirely client-side using JavaScript. I think that's easiest these days. The important API is
window.location.assign("https://www.google.com");
Note that the https://
is needed. Otherwise the URL is treated as local to the current website. You'd get taken to http://yourwebsite.com/google.com
Here's a minimal example of a HTML page which uses JavaScript to simply immediately redirect you to google.com:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Redirect to Google</title>
</head>
<body>
<script>
window.location.assign("https://google.com");
</script>
</body>
</html>

- 101
- 6