Jump to content
Larry Ullman's Book Forums
hartofboone

How Do I Setup Ex2 To Not Use .htaccess And Mod_Rewrites For Shopping?

Recommended Posts

Hi Larry,

Yep, It's 1am and I'm still working on Chapter 7-9 of your book. In the book you said you don't need to use mod_rewrites and you would tell use how. I don't see how listed for anything other than the menu links:

Chapter 8, page 232

As a reminder, the PHP script for listing the product categories is called shop.php, and it’s linked in the header as either /shop/coffee/ or /shop/goodies/. The server’s mod_rewrite module will convert that URL (unbeknownst to the user) into either shop.php?type=coffee or shop.php?type=goodies. If you’re not using mod_rewrite, then your URLs should just be those.

 

Please I don't want to use mod_rewrites. I just want the site to work. I have the main page links working using this for the shopping links:

<li><a href="/jbhart/WEB260/ex2/html/shop.php?type=coffee">Coffee</a></li>
 <li><a href="/jbhart/WEB260/ex2/html/shop.php?type=goodies">Goodies</a></li>
 <li><a href="/jbhart/WEB260/ex2/html/shop.php?type=sales">Sales</a></li>

coffee.jpg

 

Now I'm trying to get all the little icons working on each page. On the coffee page for example what is the real URL for Dark Roast, Kona, and Original blend.  What i have is the htaccess version which doesn't work and I have no idea how html is suppose to convert it to a real URL.

 

Can you tell me what the real URL is for these links so I can figure out what to change? Since this is user output we are talking about and it MVC is the file for coffee in the view subdirectory? Is it list_coffees2.html? Trying to figure out how you are generating urls is really difficult. Thanks for any help!

http://localhost/browse/coffee/Dark+Roast/2
http://localhost/browse/coffee/Kona/3
http://localhost/browse/coffee/Original+Blend/1

P.S. Don't know if it would help anyone else but if I had reviewed your book before publishing I would have suggest you make an alternate version that doesn't use .htaccess and mod_rewrites. Everyone in my class is going nuts trying to get your links and stuff to work much less figure out how to convert .htaccess to work on our IIS school server. Thanks.

 

Share this post


Link to post
Share on other sites

Thanks for the feedback! For the real URL for the products, you should be able to use:

browse.php?id=X&type=(goodies|coffee)&category=CATEGORY

You'll obviously need to replace the id, type, and category values with the proper values. 

 

All the mod_rewrite does for the browse.php page is convert browse/coffee/Dark+Roast/2 into browse.php?id=2&type=coffee&category=Dark+Roast. If you look at any of the mod_rewrite rules, hopefully it becomes more obvious how they'd be written when not using mod_rewrite. 

 

I can appreciate that mod_rewrite can be a PITA, but it really is the right way to do this kind of example. And there is a mod_rewrite equivalent for IIS: https://www.iis.net/downloads/microsoft/url-rewrite

 

LMK if you have any other questions!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...