How do you create 'short URLs'?

User avatar
John Gray
PlatinumLounger
Posts: 5405
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

How do you create 'short URLs'?

Post by John Gray »

I'm unable to Google for this feature, because I don't know what it's called!

I'm referring to the use of something short like

http://www.domain.co.uk/thispage

(no .htm or .html ending) which the user can specify instead of a huge great URL like

http://www.domain.co.uk/upperlevel/medi ... spage.html

What needs to be done on a website to enable this form of redirection? (Simple explanations only, please, to match understanding!)

Thanks!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
Leif
Administrator
Posts: 7208
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: How do you create 'short URLs'?

Post by Leif »

If you have a sub-directory called (e.g.) /this page and have a file there called 'default.htm', this page will be automatically loaded (in the same way as the default page for any website can load).

You could therefore have a 'default.htm' or ('default.html') which includes a redirection script in the <head> section to a specific page, e.g.:

Code: Select all

<SCRIPT LANGUAGE="JavaScript">
window.location.replace ("http://www.domain.co.uk/upperleve/mediumlevel/lowerlevel/evenlowerlevel/pagestore/thispage.html");
</script>
Is that the sort of thing you mean?

Or are you thinking of something like TinyURL.com - shorten that long URL into a tiny URL?
Leif

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: How do you create 'short URLs'?

Post by HansV »

Here is a long Wikipedia article about the subject: URL redirection. Depending on your setup, you may want to look at the section Using .htaccess for redirection (for Apache web servers) or Refresh Meta tag and HTTP refresh header.
Best wishes,
Hans

User avatar
John Gray
PlatinumLounger
Posts: 5405
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: How do you create 'short URLs'?

Post by John Gray »

Thanks to you both! We already use bit.ly, and formerly tinyurl, but people have complained that it isn't easy to determine the real URL from these shortened forms, so we wanted to have our website as the major component of the URL, to encourage trust.

The JavaScript example seems a neat trick, but for the resultant proliferation of directories. URL Shortening seems to be the magic phrase. together with redirection. More reading required of the links supplied...
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...