Miriam Posted March 31, 2004 Posted March 31, 2004 I have a shopping cart that requires a url that looks like this: ****/cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=LucyNewItems I'm trying to use Mod rewrite in the .htaccess file to make it more search engine friendly. Here's what I have: RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^\.htaccess$ - [F] RewriteRule ^(.*)store/(.*)$ $1cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=$2 Then on the html page, I've changed the link to: ****/store/LucyNewItems If I understand what mod rewrite is supposed to do, it should take the new link format and translate it back to the form that the database requires so as to bring up the correct product page. This isn't working. It produces a 404 file not found error. Can anyone tell me what I've done wrong and how to get this to work? Thanks, Miriam Quote
gaberville Posted March 31, 2004 Posted March 31, 2004 I am very new at this, but It looks to me like you need to use ****/store/LucyNewItems.html instead of ****/store/LucyNewItems I think you need to all the .html -gabe Quote
Miriam Posted March 31, 2004 Author Posted March 31, 2004 Good suggestions, but that didn't work either. Quote
MikeJ Posted March 31, 2004 Posted March 31, 2004 Asking the obvious question... You're definite http://****/cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=LucyNewItems is the correct location and it works when you go to it directly? When I used this rule: RewriteRule ^(.*)store/(.*)$ $1php/test/redtest.php?db=goodies.txt&merchant=goodies&search=$2 My little PHP test script runs and outputs: Requested URL: /store/LucyNewItems File actually served: /php/test/redtest.php Arguments Passed: db=goodies.txt&merchant=goodies&search=LucyNewItems Quote
Miriam Posted March 31, 2004 Author Posted March 31, 2004 Yes, using the correct domain: "http://64.39.23.130/cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=LucyNewItems", if you put that in the url address, you will be taken to the product page. Could you explain the test that you wrote so I could try it? Did you write in an .htaccess file? How did you run it to test it? Did your test show that this should have worked? Thank you for your help... Miriam Quote
MikeJ Posted March 31, 2004 Posted March 31, 2004 Yea. When I tested it, it seemed to work. My .htaccess (made it similar to yours): >RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^\.htaccess$ - [F] RewriteRule ^(.*)store/(.*)$ $1php/test/redtest.php?db=goodies.txt&merchant=goodies&search=$2 The redtest.php file: ><?php print("Requested URL: ".$REQUEST_URI."<br>File actually served: ".$PHP_SELF."<br>Arguments Passed: ".$QUERY_STRING); ?> When I request http://****/store/LucyNewItems the output I get is: Requested URL: /store/LucyNewItemsFile actually served: /php/test/redtest.php Arguments Passed: db=goodies.txt&merchant=goodies&search=LucyNewItems Quote
Miriam Posted March 31, 2004 Author Posted March 31, 2004 I'm studying your code and trying to understand it.... but not really understanding it at all So if I wrote the code in the .htaccess file correctly, why isn't it working? Sorry for being so dense. Thanks, Miriam Quote
Miriam Posted April 1, 2004 Author Posted April 1, 2004 Mike, Do you have any other suggestions on how I can get this to work? Thanks, Miriam Quote
MikeJ Posted April 2, 2004 Posted April 2, 2004 Unfortunately, no. Do you have anything else in your .htaccess file or is that all of it? And also, just to cover the bases, this .htaccess file is located in your public_html directory, and is world readable (world has read permission enabled)? Quote
Miriam Posted April 4, 2004 Author Posted April 4, 2004 Mike, just to let you know, I copied and pasted what you wrote into my .htaccess file, then changed to the correct path names...and it works! I couldn't see anything that I had typed differently that you, but there must have been something, 'cause it definitely liked what you typed better. I have accomplished getting the pages to look like static url's. I'm now going to re-submit to the search engines and hope to get better placement. Thanks so much for your help! Miriam Quote
gaberville Posted April 4, 2004 Posted April 4, 2004 It's a little late, but I found this link that might be useful. rewriterule-generator Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.