GIDForums  

Go Back   GIDForums > Web Hosting Forums > Apache Web Server Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Dec-2003, 06:09
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road

Need rewrite help for cgi script Shop cart


I'm trying to take this and make it basically look like directories for starters:

http://www.xxxxxxxx.com/shop/cgi-bin/cp-app.cgi?usr=51F6296048&rnd=8879364&rrc=N&affl=&cip =&act=&aff=&pg=prod&ref=SS-JETEPHS008029&cat=&catstr=

Using this:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /prod
RewriteRule cp-app/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/(\.*)/$ /\/shop/cgi-bin/cp-app\.cgi?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10&$11=$12&$1 3=$14&$15=$16&$17=$18&$19=$20&$21=$22

But it's not working.

Being a novice at this.....if I can make it all directories, my next move would be to have someone help me shrink it down to just 2 variables for search engine friendliness. But I can't seem to make it work even into a long directory string.

Also, once I shrink it down do you recommend ending in something like /prod/SS-JETEPHS008029/51F6296048- with no file name or use the product number as a file like /SS-JETEPHS008029.html ????

This is all new to me and I could use someones help looking at the rule above.

Thanks!!!!
  #2  
Old 22-Dec-2003, 17:39
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Now, I don't know if the code you posted was 'modified' by this forum script (since I have just upgraded the forums) but this search pattern is not right:

Code:
(\.*)

What that means is that the rule should match 0 or more dots!

What your pattern should look like is this:

Code:
([^/]*)
  #3  
Old 22-Dec-2003, 18:20
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road
ok here is the url I'm trying to rewrite as all directories:

http://www.itsalreadysigned4u.com/shop/cgi-bin/cp-app.cgi?usr=51F9431182&rnd=5224483&rrc=N&affl=&cip =65.32.153.69&act=&aff=&pg=prod&ref=SS-JETEPHS008029&cat=&catstr=

Below is the code used in .htaccess as I've changed to what you stated:

Options +FollowSymLinks
RewriteEngine on
RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ /\/shop/cgi-bin/cp-app\.cgi?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10&$11=$12&$1 3=$14&$15=$16&$17=$18&$19=$20&$21=$22

Can you look carefully at this and tell me if this is now correct thru and thru?

Once I've successfully gotten it to write all as directories I'll want to remove some of the variables and shrink it down, but I need to make this work right?

Is my rule above correct?



Quote:
Originally Posted by JdS
Now, I don't know if the code you posted was 'modified' by this forum script (since I have just upgraded the forums) but this search pattern is not right:

Code:
(\.*)

What that means is that the rule should match 0 or more dots!

What your pattern should look like is this:

Code:
([^/]*)
  #4  
Old 22-Dec-2003, 18:30
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Okay, here are a few fixes that I think you should address:

Code:
$1=$2&...

should be
Code:
usr=$1&rnd=$2&...

Then, this part:

Code:
/\/shop/cgi-bin/cp-app\.cgi?

could just be

Code:
shop/cgi-bin/cp-app.cgi?

So a sample of this rewrite rule could now look like this:

Code:
RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&...etc
  #5  
Old 22-Dec-2003, 19:01
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road
ok this is what I have....

Options +FollowSymLinks
RewriteEngine on
RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&rrc=$3&affl=$4&cip=$5&act=$6 &aff=$7&pg=$8&ref=$9&cat=$10&catstr=$11

But for some reason I'm still getting no change in the url.


Quote:
Originally Posted by JdS
Okay, here are a few fixes that I think you should address:

Code:
$1=$2&...

should be
Code:
usr=$1&rnd=$2&...

Then, this part:

Code:
/\/shop/cgi-bin/cp-app\.cgi?

could just be

Code:
shop/cgi-bin/cp-app.cgi?

So a sample of this rewrite rule could now look like this:

Code:
RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&...etc
  #6  
Old 22-Dec-2003, 20:05
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Quote:
Originally Posted by theblade24
... But for some reason I'm still getting no change in the url.
Well for one, your matched patterns total > 11; while your rule rewrites just 11, so your cgi script may be bombing (missing some required variables).

Also, how do the links appear on your web pages now, if looking at your website, they have not been changed yet, so it's hard to say what's wrong.

Why don't you create a test page and upload it to your live server with a little less variables in your query string; just until you understand how all this works?

For example you could write a simple PHP page, filename it test.php, then insert the following code:
PHP Code:

<?php
echo "<pre>\r\n";
print_r( $_GET );
echo "</pre>\r\n";
?>


Append the rewrite rule below to your existing .htaccess file and upload it too:

Code:
Options +FollowSymLinks RewriteEngine on RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&rrc=$3&affl=$4&cip=$5&act=$6&aff=$7&pg=$8&ref=$9&cat=$10&catstr=$11 # JUST TESTING... RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)/$ test.php?type=$1&pg=$2&lang=$3 [L]

Now in your browser's address bar, type:

http://www.itsalreadysigned4u.com/test/article/1/en/

hit ENTER and see what happens...
  #7  
Old 23-Dec-2003, 04:45
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road
ok it returns this:

Array
(
[type] => article
[pg] => 1
[lang] => en
)

Which I'm assuming is what you wanted?


Quote:
Originally Posted by JdS
Well for one, your matched patterns total > 11; while your rule rewrites just 11, so your cgi script may be bombing (missing some required variables).

Also, how do the links appear on your web pages now, if looking at your website, they have not been changed yet, so it's hard to say what's wrong.

Why don't you create a test page and upload it to your live server with a little less variables in your query string; just until you understand how all this works?

For example you could write a simple PHP page, filename it test.php, then insert the following code:
PHP Code:

<?php
echo "<pre>\r\n";
print_r( $_GET );
echo "</pre>\r\n";
?>


Append the rewrite rule below to your existing .htaccess file and upload it too:

Code:
Options +FollowSymLinks RewriteEngine on RewriteRule cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&rrc=$3&affl=$4&cip=$5&act=$6&aff=$7&pg=$8&ref=$9&cat=$10&catstr=$11 # JUST TESTING... RewriteRule ^test/([^/]*)/([^/]*)/([^/]*)/$ test.php?type=$1&pg=$2&lang=$3 [L]

Now in your browser's address bar, type:

http://www.itsalreadysigned4u.com/test/article/1/en/

hit ENTER and see what happens...
  #8  
Old 23-Dec-2003, 05:10
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road
This is how a current product url looks that I'm trying to rewrite and shorten:

http://www.itsalreadysigned4u.com/shop/cgi-bin/cp-app.cgi?usr=51F9431182&rnd=6263554&rrc=N&affl=&cip =65.32.153.69&act=&aff=&pg=prod&ref=SS-JETEPHS008029&cat=&catstr=

Here is current rule based on your suggestions:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^cp-app/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/$ shop/cgi-bin/cp-app.cgi?usr=$1&rnd=$2&rrc=$3&affl=$4&cip=$5&act=$6 &aff=$7&pg=$8&ref=$9&cat=$10&catstr=$11 [L]
  #9  
Old 26-Dec-2003, 06:41
theblade24 theblade24 is offline
New Member
 
Join Date: Dec 2003
Posts: 11
theblade24 is on a distinguished road
Hello, JDS, hope you had a great holiday. Can you look at my above post and continue our discussion please?
  #10  
Old 27-Dec-2003, 01:44
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
I assumed the discussion was over since all you have to do now is to change all the links on your web pages to look like this... for example:

HTML Code:
<!-- >> sample: OLD LINK <a href="/shop/cgi-bin/cp-app.cgi?usr=51F9431182&rnd=6263554&rrc=N&affl=&cip=65.32.153.69&act=&aff=&pg=prod&ref=SS-JETEPHS008029&cat=&catstr=">Click Here</a> >> is replaced by sample: NEW, SEARCH ENGINE FRIENDLY VERSION LINK.. --> <a href="/cp-app/51F9431182/6263554/N/NULL/65.32.153.69/NULL/NULL/prod/SS-JETEPHS008029/NULL/NULL/">Click Here</a>

I don't know how it should be handling "blank" variables so I simply added "NULL" just so that the URLS don't look awkward in a browser's address bar.
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:48.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.