Solved

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

Posted on 2006-11-20
16
3,970 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
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
Yup my mod_rewrite is loaded. I am putting this in my browser:

http://mydomain.com/cgi-bin/rewrite.cgi?request_id=index

which should reqrite it to this but doesn't:

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
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

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

695 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