Solved

My webpage bookmarks are extra long.. Can a CGI help shorten my links??

Posted on 2006-11-20
16
3,962 Views
Last Modified: 2013-12-25
If someone would want to go to an exact pageon my website, they'd have to put a lot of parameters in the link to get there. For example, this is just to get to my home page:

http://mydomain.com/cgi-bin/livescript.bat?co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=&request_id=index

Most of my webpages share one part of the address all the time: &co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=

Is there a way where I can create a script that I can give someone my link as http://mydomain.com/cgi-bin/rewrite.cgi?request_id=index

What rewrite.cgi will do is transform that to the first link above, which is the real one. How would you do this? Any help is greatly appreciated.
0
Comment
Question by:bemara57
  • 4
  • 4
  • 3
  • +2
16 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 17984776
Do you have control of the webserver, as this is a better job for the webserver to perform?

If you do want to use a CGI program, how many different parameters do you want it to accept?

In your example, you have

rewrite.cgi?request_id=index

What other values for request_id can there be?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17985737
yes a cgi can help, as Tintin explained, but I'd use the web server to do the rewriting. Which web server do you use?
0
 

Author Comment

by:bemara57
ID: 17987040
I do have full control of the server. I am using Apache 1.3
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 17987990
then I'd use mod_rewrite, something like:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/cgi-bin/rewrite.cgi
RewriteRule ^/cgi-bin/rewrite.cgi?(.*)$ /cgi-bin/livescript.bat?co_id=LU/&LOC_NO=001&reqr_type=O&reqr_id=NEW%20CUSTOMER&AUTH_ID=&$1
0
 

Author Comment

by:bemara57
ID: 17988201
Should I put this in my VirtualHost section because I am using virtualhosting. Or should I put this in the <Directory> section for the location of the DocumentRoot?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17989803
Put in your VirtualHost section.
0
 

Author Comment

by:bemara57
ID: 17990104
It says page cannot be found. Doesn't look like its doing any rewriting. Copied exactly what you wrote up there. Even restarted apache. Any other settings that I have to turn on?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17990249
What URL did you specify in your browser?

Is mod_rewrite loaded? (check that it's uncommented in httpd.conf)
0
 

Author Comment

by:bemara57
ID: 17991095
0
 
LVL 48

Expert Comment

by:Tintin
ID: 17991357
Does it redirect at all, ie: does it redirect to the wrong URL?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17993897
silly question: you added exactly 3 lines each beginning with Rewrite ?
There're no line breaks in my posted configuration lines.

If it still fails, please check your error_log and access_log, and post messages if any (according this request).
0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 18206378
As written, I think it's looking for a script called rewrite.cgi, which I assume you don't have, hence the page not found errors...

0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 19344363
I think ahoffmann's suggestion to use mod_rewrite was the correct approach and, after a bit of tweaking, likely resulted in the probelm being solved and thus the question abandoned.  Shouldn't he get the points in the absence of any comment from the questioner?
0
 
LVL 6

Expert Comment

by:nitinsawhney
ID: 19989897
A better way could be writing rewrite rules in .htacess file.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

770 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