Solved

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

Posted on 2004-09-01
25
828 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
ID: 11950495
You could try my website:

http://www.0url.com

-Ram
0
 
LVL 5

Expert Comment

by:rsriprac
ID: 11950516
0
 
LVL 11

Accepted Solution

by:
neester earned 500 total points
ID: 11950604
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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 11

Expert Comment

by:neester
ID: 11950632
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
ID: 11950989
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
ID: 11951161
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
ID: 11951823
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
ID: 11951853
>> 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
ID: 11952005
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
ID: 11952080
"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
ID: 11952089
It'll take 5 seconds tops.  Heh.

-Ram
0
 
LVL 11

Expert Comment

by:neester
ID: 11952712
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
 
LVL 5

Expert Comment

by:rsriprac
ID: 11953079
O, I ment using the 0url.com

-Ram
0
 
LVL 11

Expert Comment

by:neester
ID: 11953224
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
ID: 11953422
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
ID: 11953443
... and wtf is a "Banking Website"?  No I don't get your drift.

-Ram
0
 
LVL 11

Expert Comment

by:neester
ID: 11953571
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
ID: 11958894
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
ID: 11959014
Thanks :)
If you need any help post here again.
Thanks for the "A"
0
 
LVL 6

Expert Comment

by:Fahdmurtaza
ID: 11960597
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
ID: 11960813
No worries Fahd :)

Glad to help you out!
0
 
LVL 11

Expert Comment

by:neester
ID: 11960825
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
ID: 11960893
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
ID: 11960935
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
ID: 15132486
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

828 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