Apache Mod Rewrite .htaccess

liunx

Guest
I have a shopping cart that requires a url that looks like this:<br /><br />****/cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=LucyNewItems<br /><br />I'm trying to use Mod rewrite in the .htaccess file to make it more search engine friendly. Here's what I have:<br /><br />RewriteEngine on<br />Options +FollowSymlinks<br />RewriteBase /<br />RewriteRule ^\.htaccess$ - [F]<br />RewriteRule ^(.*)store/(.*)$ $1cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=$2<br /><br />Then on the html page, I've changed the link to:<br /><br />****/store/LucyNewItems<br /><br />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.<br /><br />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?<br /><br />Thanks,<br />Miriam<!--content-->
I am very new at this, but It looks to me like you need to use<br /><br />****/store/LucyNewItems.html<br /><br />instead of <br /><br />****/store/LucyNewItems<br /><br />I think you need to all the .html<br /><br /><br />-gabe<!--content-->
Good suggestions, but that didn't work either.<!--content-->
Asking the obvious question...<br /><br />You're definite <!--coloro:blue--><span style="color:blue"><!--/coloro-->http://****/cgi-bin/cart/cart.pl?db=goodies.txt&merchant=goodies&search=LucyNewItems<!--colorc--></span><!--/colorc--> is the correct location and it works when you go to it directly?<br /><br />When I used this rule:<br /><!--fonto:courier--><span style="font-family:courier"><!--/fonto-->RewriteRule ^(.*)store/(.*)$ $1php/test/redtest.php?db=goodies.txt&merchant=goodies&search=$2<!--fontc--></span><!--/fontc--><br /><br />My little PHP test script runs and outputs:<br /><!--fonto:courier--><span style="font-family:courier"><!--/fonto-->Requested URL: /store/LucyNewItems<br />File actually served: /php/test/redtest.php<br />Arguments Passed: db=goodies.txt&merchant=goodies&search=LucyNewItems<!--fontc--></span><!--/fontc--><!--content-->
Yes, using the correct domain:<br /><br />"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.<br /><br />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? <br /><br />Thank you for your help...<br />Miriam<!--content-->
Yea. When I tested it, it seemed to work.<br /><br />My .htaccess (made it similar to yours):<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteEngine on<br />Options +FollowSymlinks<br />RewriteBase /<br />RewriteRule ^\.htaccess$ - [F]<br />RewriteRule ^(.*)store/(.*)$ $1php/test/redtest.php?db=goodies.txt&merchant=goodies&search=$2<!--c2--></div><!--ec2--><br /><br />The redtest.php file:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php<br />    print("Requested URL: ".$REQUEST_URI."<br>File actually served: ".$PHP_SELF."<br>Arguments Passed: ".$QUERY_STRING);<br />?><!--c2--></div><!--ec2--><br /><br />When I request <!--coloro:blue--><span style="color:blue"><!--/coloro-->http://****/store/LucyNewItems<!--colorc--></span><!--/colorc--> the output I get is:<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Requested URL: /store/LucyNewItems<br />File actually served: /php/test/redtest.php<br />Arguments Passed: db=goodies.txt&merchant=goodies&search=LucyNewItems<!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
I'm studying your code and trying to understand it.... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> but not really understanding it at all <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /><br /><br />So if I wrote the code in the .htaccess file correctly, why isn't it working? <br /><br />Sorry for being so dense.<br /><br />Thanks,<br />Miriam<!--content-->
Moving to better forum for organization.<!--content-->
Mike,<br />Do you have any other suggestions on how I can get this to work?<br />Thanks,<br />Miriam<!--content-->
Unfortunately, no. Do you have anything else in your .htaccess file or is that all of it?<br /><br />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)?<!--content-->
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. <br /><br />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.<br /><br />Thanks so much for your help!<br /><br />Miriam<!--content-->
It's a little late, but I found this link that might be useful.<br /><br /><a href="http://www.webmaster-toolkit.com/mod_rewrite-rewriterule-generator.shtml" target="_blank">rewriterule-generator</a><!--content-->
 
Back
Top