Solved

Alias for a very long URL .. a temporary or semi permanent abbreviation

Posted on 2004-09-01
25
824 Views
Last Modified: 2011-10-03

I got this URL (and a few more) in an email

http://www.macquarie.com.au/ws/newslettertracking/NewsletterTrackingServle
t?newsletterId=1159046&newsletterTypeCodeParm=[NEWSLETTER_TYPE]&emailAddrP
arm=[EMAIL_ADDRESS]&requestedURLParm=http://www.macquarie.com.au/retail/ac
robat/emg/currencymatrix.pdf&storyHeadingParm=Currency%20Warrants%20Matrix
%20(PDF)&documenttosend=newsletter_track&storyDateParm=01-Jan-1970

seems a fraction too long to me. So I started thinking .. is there not some way of programatically creating a temporary or semi-permanent URL or at least some alias to the above? So the URL in the email could read something like www.fred.com.au/CurrencyWarrantsMatrix and redirects to the rather longer version above?

How could I do that programatically?

0
Comment
Question by:Mutley2003
  • 11
  • 7
  • 3
  • +3
25 Comments
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
You could try my website:

http://www.0url.com

-Ram
0
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
0
 
LVL 11

Accepted Solution

by:
neester earned 500 total points
Comment Utility
Using .HTACCESS

Make a file called:

.htaccess

add this:

ReWriteEngine On
ReWriteRule ^shortlink.html$ http://www.macquarie.com.au/ws/newslettertracking/NewsletterTrackingServlet?newsletterId=1159046&newsletterTypeCodeParm=[NEWSLETTER_TYPE]&emailAddrParm=[EMAIL_ADDRESS]&requestedURLParm=http://www.macquarie.com.au/retail/acrobat/emg/currencymatrix.pdf&storyHeadingParm=Currency%20Warrants%20Matrix%20(PDF)&documenttosend=newsletter_track&storyDateParm=01-Jan-1970


where - shortlink.html is the NEW address...

eg:
http://www.macquarie.com.au/shortlink.html
will then load that page with the HUGE string!

:)
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
With that method you can actually add other code...

eg:

ReWriteRule ^shortlink_([0-9]+).html$ ...xxx...

^ notice the ([0-9]+)
that means, that rule will apply ONLY when, the page they are loading is called:

shortlink_12.html
shortlink_52.html
shortlink_3123.html
shortlink_123123123.html
it must be NUMERIC in that spot.

THEN
you can insert it into the page you are loading...
eg:

http://www.macquarie.com.au/ws/page.php?page_id=$1

where the $1 = the 1st Variable you have.
In theory you can have:


ReWriteRule ^shortlink_([0-9]+)_([a-z]+)__([0-9]+).html$ loadpage.php?page_number=$1&page_title=$2&article_number=$3

:)





0
 
LVL 6

Expert Comment

by:Fahdmurtaza
Comment Utility
I am not very clear about your problem but I think such links are actually link refferers or what you say pointers to some counter script which actually is used to know by the respective domain that what webs are being visited using their links. It actually helps them tell their affilate how many people moved to their site using their own web. However the thing you have menioned can be done using an asp script which uses a redirection algorithm in such a way like you have got the refferes page at

http://www.macquarie.com.au/ws/

and you want to go to another links. These links are stored any where like these can be in a database. A site script like linkrefferer.asp recieves some parameter say id="some number" and then seaches database for that id then redirects the url to that required link on your site.(e.g using response.redirect method)
In such a way your link can be easily summarised to somethin like..

http://www.macquarie.com.au/ws/linkrefferer.asp?id=9

Ok I think I solved your problem. This is the easiest method for managing a huge database of links.

Regards
Fahd Murtaza
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
Actually - I would have to diagress with Fahd,

I think HTACCESS is much more powerful and doesnt require an exploitable ASP script.
Although its also user preference.
0
 

Expert Comment

by:fetchmaster
Comment Utility
How many links are there to rewrite like this? Actually both of the solutions are ok in your case.

Just one or two, use HTACCESS method,
Hundreads, thousands, Millions, use Database Method.

One more thing. to get a a better perfomance, use the HTACCESS directives in httpd.conf file itself. This can be done by adding a virtual directory container. Do this if you are concerned about speed and, yes if you have server access too ;)
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
>> Just one or two, use HTACCESS method,
>> Hundreads, thousands, Millions, use Database Method.

Actually i would of said that HTACCESS is applicable in both cases.
Using Regluar Expressions to create only a few Rules.
0
 

Expert Comment

by:fetchmaster
Comment Utility
needster, see, if just one URL is there which have to be redirected, the HTACCESS si enough

BUT

http://www.macquarie.com.au/ws/mailServlet?blah=blah&blah2=blah2..........
must be very different from
http://www.macquarie.com.au/ws/checkoutServlet?step=2&item=item...........

How can you redirect the Traffic easily? It will be very complex and will take hours to debug(if it is possible). Thats why i asked how many URLs that has to be redirected. If it is limited, it can be done using YOUR method indeed. But for higher number of URLs, it would be good if one intermediate(using database, yes) page that gets the destination url from a table and do the redirection automatically.

0
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
"creating a temporary or semi-permanent URL or at least some alias to the above"

My solution sounds best tho. (=

-Ram
0
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
It'll take 5 seconds tops.  Heh.

-Ram
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
rsriprac

Your solution is a "hack"
it involves coding a seperate CGI file.
Where as you could use the servers built in HTACCESS method.
Which is renound for security when implemented properly.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
O, I ment using the 0url.com

-Ram
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
Awwww that!

The only bad thing is.
The website in question is a Banking Website.
So offsite links look a little - "dodgy"
If  you get my drift.
0
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
I dont know if you notice, but the question seem to be address TWO different domains, hence implying that it is an offsite page.

-Ram
0
 
LVL 5

Expert Comment

by:rsriprac
Comment Utility
... and wtf is a "Banking Website"?  No I don't get your drift.

-Ram
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
http://www.macquarie.com.au/au/index.html

its a BANK - as in people do Banking there...
Online banking etc...
0
 

Author Comment

by:Mutley2003
Comment Utility
OK OK OK. ENOUGH ALREADY! THANK YOU THANK YOU THANK YOU , but I have enough now.

I like htaccess best, but ASP maybe, and 0URL is cool but I am a little uncomfortable with going offsite.

bye


0
 
LVL 11

Expert Comment

by:neester
Comment Utility
Thanks :)
If you need any help post here again.
Thanks for the "A"
0
 
LVL 6

Expert Comment

by:Fahdmurtaza
Comment Utility
Good wishes for your A I nver used htaccess method and now I will. I think it will also solve some redirection problems of mine too. Well thanks for the help as I am planning to use htaccess onwards in my new asp projects.
Regards
Fahd Murtaza
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
No worries Fahd :)

Glad to help you out!
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
BTW TO answer  "fetchmaster"

You can use regular expressions, which make it A LOT easier than having a dbase of links.
In the worst case with HTAccess.
its the same as the DBASE of redirects, you will just need to create a new rule for each link.
In the best case.
1,000,000,000,000 database entries OR 1 rule in hTACCESS

HTAccess has the advantage over dbase entries, hands down...
0
 

Expert Comment

by:fetchmaster
Comment Utility
Mutley2003, I understand thats enough. But let me clarify something more. It should be done , i think.


needster,  there is no doubt apache rewrite(that htaccess thingy) is useful and I also use it for redirection. But I dont understand why you missed my point. Are you telling about creating hundreads of(1,000,000,000,000) "shortlink_XXXXX.html" pages? Im very sorry.


>  I am planning to use htaccess onwards in my new asp projects.
HTACCESS is only for Apache Servers. Just recalled!!
0
 
LVL 11

Expert Comment

by:neester
Comment Utility
fetchmaster.

you have have a rule like this:


ReWriteRule single_link_with_numeric_ending_([0-9]+).html longurl/far/fromthe/orginal/file/but/is/php/with/input/variable.php?id=$1

that one rule will satisfy millions of pages.
everypage that you load, eg:

single_link_with_numeric_ending_12.html
single_link_with_numeric_ending_1142.html
single_link_with_numeric_ending_1231231.ht1ml
single_link_with_numeric_ending_1.html
single_link_with_numeric_ending_11312342.html
single_link_with_numeric_ending_13453452.html

they all will nav to the PHP file, in input that variable.
eg: for a blog to load a specific blog entry, you can use this, or a news website with article that are numbered etc...

if you used a dbase, that example would take 6 entries...
0
 
LVL 9

Expert Comment

by:smidgie82
Comment Utility
The rewrite engine has some crazy powerful features, to the extent that you could even combine the two methods discussed above (database vs. htaccess) using something like the following:

RewriteEngine On
RewriteMap db_map prg:some_program
RewriteRule ^shortlink.html$ ${db_map:$1}

where some_program accepts a URL on STDIN, looks it up in a database somehow, and writes the new URL back to STDOUT.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This video teaches users how to migrate an existing Wordpress website to a new domain.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now