I am REALLY struggling with this book I bought on e-commerce. Things aren’t working as they are supposed to work. ![]()
(The chapter I am in is a Product Catalog and he is trying to show how to use MOD_REWRITE to make your URL’s “prettier” and more SEO-friendly.)
The author says this should be displayed in the URL for the customer…
shop/coffee
but then he is rewriting it for the Search Engines like this…
shop.php?type=coffee
I don’t understand how this can work when all you see in the address bar is…
http://localhost/02_MyCoffeeShop/shop/coffee/
Another PROBLEM I am having is that when I click from Category to Category the URL is building off itself and not refreshing so I keep getting incorrect links like this…
http://localhost/02_MyCoffeeShop/shop/goodies/shop/coffee/
I have been stuck on this stupid chapter and example for a week now!! ![]()
My goal is to finish the book and see how things work, and then I can go back and re-code things once I understand how they originally worked.
QUESTIONS:
1.) How do you turn on MOD_REWRITE?
I am working locally on my MacBook using NetBeans, and maybe the last problem I described is because the MOD_REWRITE code in my .htaccess file isn’t turned on/working?!
I created a .htaccess file and have it in my root development directory.
.htaccess file
[SIZE="1"]<IfModule mod_rewrite.c>
RewriteEngine on
# For sales:
RewriteRule ^shop/sales/?$ sales.php
# For the primary categories:
RewriteRule ^shop/([A-Za-z\\+]+)/?$ shop.php?type=$1
# For specific products:
RewriteRule ^browse/([A-Za-z\\+\\-]+)/([A-Za-z\\+\\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3
# For HTTPS pages:
RewriteCond %{HTTPS} off
RewriteRule ^(checkout\\.php|billing\\.php|final\\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
[/SIZE]
2.) If you make a URL “friendly” like this…
www.SomeSite.com/like/to/specific/product
then how does your browser know where to navigate??
Is the re-written URL hidden in the background?
Is that how a MOD_REWRITE works?
I could really use some help here. (I’d like to get this fixed tonight or Sunday at the latest.)
Thanks,
Debbie