dbecker1948 Posted April 1, 2014 Share Posted April 1, 2014 I have read the book!, but the Mod_rewrite statements will not access the menu items. I have tried all the suggestions in the book. I am trying to use this book in a university course and regret my decision. Could you please send me a working site and the code that really does work? Link to comment Share on other sites More sharing options...
HartleySan Posted April 1, 2014 Share Posted April 1, 2014 Are you able to get mod_rewrite to work with simple examples? Could you please provide us with some more info and code so that we can better help you? Thanks. Link to comment Share on other sites More sharing options...
dbecker1948 Posted April 1, 2014 Author Share Posted April 1, 2014 Here is the code in the .htaccess # Disable directory browsing:Options All -Indexes # Prevent folder listing:IndexIgnore * # Prevent access to any file:<FilesMatch "^.*$">Order Allow,Deny Deny from all</FilesMatch><IfModule mod_rewrite.c>RewriteEngine onRewriteBase /ex2/# 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} offRewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]</IfModule> This file is located in the includes folder Here are the menu items <ul class="nav"> <!-- MENU --> <li><a href="./shop/coffee">Coffee</a></li> <!-- <li><a href="/shop/coffee/">Coffee</a></li> --> <li><a href="./shop/shop.php">Goodies</a></li> <li><a href="./sales.php">Sales</a></li> <li><a href="./wishlist.php">Wish List</a></li> <li><a href="./cart.php">Cart</a></li> <!-- END MENU --> </ul> The first three will not access the pages and the last three, I simply put the reference to the correct file and they will bring up the page but it still has errors. That's because there is so much redirections that the program seems to be confused. Link to comment Share on other sites More sharing options...
HartleySan Posted April 2, 2014 Share Posted April 2, 2014 The first three will not work because your regex is too strict. According to your regex, after /shop, you have to have another /, but none of your links do, thus they will not work. As a side note, your second rewrite rule completely trumps your first rewrite rule, making it pointless. As for the last three, I cannot comment on the errors without seeing the related code in the scripts themselves, but likely, you are accessing them without all the proper information. Just to reassure you though, mod_rewrite is a tricky beast and takes some practice. I got quite annoyed at it myself before I finally got it down. Keep at it, and you'll be okay. 1 Link to comment Share on other sites More sharing options...
Recommended Posts