Solved

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

Posted on 2006-11-20
16
3,959 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

705 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

21 Experts available now in Live!

Get 1:1 Help Now