michaelnwani Posted March 11, 2012 Share Posted March 11, 2012 Hello everyone, PHP Version 5.3.6 Running MAMP Version 2.0.5 and everything else seems to be up to date I'm having some troubles with displaying the website and .htaccess, if you would be so kind as to assist me. My html isn't appearing on the main page, and when I click on any link, like for instance Sales, I get the error "Not Found. The requested URL /shop/sales/ was not found on this server." I just figure the more information I give, the easier it is to see the problem. All of my files are inside htdocs/html2, and my .htaccess root file is right in the html2 folder: <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> I then have the .htaccess implemented in your (Larry Ullman) book in my includes directory: # Disable directory browsing: Options All -Indexes # Prevent folder listing: IndexIgnore * # Prevent access to any file: <FilesMatch "^.*$"> Order Allow,Deny Deny from all </FilesMatch> I'm not positive if these have anything to do with it but in my config.inc.php in the includes directory, I have these as my settings: define ('BASE_URI', '/Applications/MAMP/htdocs/html2/'); define ('BASE_URL', 'localhost:8888/'); define ('MYSQL', '/Applications/MAMP/htdocs/mysql.inc.php'); Images aren't appearing, too... I have my header and footer.html's in my includes folder, entirely the same structure as you had Link to comment Share on other sites More sharing options...
michaelnwani Posted March 11, 2012 Author Share Posted March 11, 2012 As for my stored procedures, they seem to have worked as in they all appear under my coffee database ("coffeedb") in the Routines section, and I tested them. Link to comment Share on other sites More sharing options...
michaelnwani Posted March 11, 2012 Author Share Posted March 11, 2012 Just providing more information that I'm guessing may be relevant to helping resolve this issue... In my header.html, I have this as the menu code <!-- MENU --> <li><a href="/shop/coffee/">Coffee</a></li> <li><a href="/shop/goodies/">Goodies</a></li> <li><a href="/shop/sales/">Sales</a></li> <li><a href="/wishlist.php">Wish List</a></li> <li><a href="/cart.php">Cart</a></li> <!-- END MENU --> I'd also like to think I am allowed .htaccess overrides by the hosting company because the change in the url is actually reflected as /shop/whatever and the .htaccess in my includes is also reflected. Link to comment Share on other sites More sharing options...
Larry Posted March 12, 2012 Share Posted March 12, 2012 You need to change your BASE_URL to include the html2 folder. Then you need to change all your HTML to use html2 before links, CSS, and image references. Link to comment Share on other sites More sharing options...
michaelnwani Posted March 13, 2012 Author Share Posted March 13, 2012 I changed the folder to html (I had to do it as html2 before but I had another folder named html however I changed its name), and made this my config: define ('BASE_URI', '/Applications/MAMP/htdocs/html/'); define ('BASE_URL', 'localhost:8888/Applications/MAMP/htdocs/html/'); define ('MYSQL', '/Applications/MAMP/htdocs/mysql.inc.php'); I also tried just 'localhost:8888/html/' as the BASE_URL, however the problem still persists :/. It just gives me (for example) "Not Found The requested URL /shop/coffee/ was not found on this server." on any link I click, and the styling still won't appear so it's a blank screen... I have my folder set up the exact same way as in your examples Link to comment Share on other sites More sharing options...
michaelnwani Posted March 13, 2012 Author Share Posted March 13, 2012 Quite strange... adding in "/html/" makes these links work and even the css appeared on the page: <link href="/html/css/style.css" rel="stylesheet" type="text/css" /> <ul class="nav"> <!-- MENU --> <li><a href="/html/shop/coffee/">Coffee</a></li> <li><a href="/html/shop/goodies/">Goodies</a></li> <li><a href="/html/shop/sales/">Sales</a></li> <li><a href="/html/wishlist.php">Wish List</a></li> <li><a href="/html/cart.php">Cart</a></li> <!-- END MENU --> </ul> I think I have to /html/ everything, including images if I want them to appear but I honestly am not sure why. Link to comment Share on other sites More sharing options...
Edward Posted March 13, 2012 Share Posted March 13, 2012 May be because you have your server root set to localhost:8888/ and not localhost:8888/html/ Link to comment Share on other sites More sharing options...
michaelnwani Posted March 14, 2012 Author Share Posted March 14, 2012 My server root, would it be BASE_URL? Because I had already changed it to localhost:8888/html/ and it did not affect anything Link to comment Share on other sites More sharing options...
Edward Posted March 14, 2012 Share Posted March 14, 2012 What URL are you typing in your browser to load up the application? Link to comment Share on other sites More sharing options...
michaelnwani Posted March 14, 2012 Author Share Posted March 14, 2012 I just put in localhost:8888 and then my folder choices come up, with html being one of them. And when I click on html it takes me to the index.php page, and the browser is stated as "localhost:8888/html", not even index.php. Link to comment Share on other sites More sharing options...
Larry Posted March 14, 2012 Share Posted March 14, 2012 Okay, so BASE_URL would be http://localhost:8888/html I forget offhand whether there should be a slash after that or not. The reason you need to use /html/ in all your links, images, and CSS is that your Web site isn't in the root directory. So /somefile assumes that somefile is in Applications/MAMP/htdocs, but that's not where you put it. You put it in Applications/MAMP/htdocs/html Link to comment Share on other sites More sharing options...
Edward Posted March 14, 2012 Share Posted March 14, 2012 Quite strange... adding in "/html/" makes these links work and even the css appeared on the page: <link href="/html/css/style.css" rel="stylesheet" type="text/css" /> <ul class="nav"> <!-- MENU --> <li><a href="/html/shop/coffee/">Coffee</a></li> <li><a href="/html/shop/goodies/">Goodies</a></li> <li><a href="/html/shop/sales/">Sales</a></li> <li><a href="/html/wishlist.php">Wish List</a></li> <li><a href="/html/cart.php">Cart</a></li> <!-- END MENU --> </ul> I think I have to /html/ everything, including images if I want them to appear but I honestly am not sure why. You are doing the right thing here by putting the /html/ in front links, images and css references. It was what Larry was instructing you to do in the post. This is coffee shop right, which php page is this stuff running of, then i can see why you need that /html/ folder before things? Link to comment Share on other sites More sharing options...
michaelnwani Posted March 14, 2012 Author Share Posted March 14, 2012 Okay, so BASE_URL would be http://localhost:8888/html I forget offhand whether there should be a slash after that or not. The reason you need to use /html/ in all your links, images, and CSS is that your Web site isn't in the root directory. So /somefile assumes that somefile is in Applications/MAMP/htdocs, but that's not where you put it. You put it in Applications/MAMP/htdocs/html I definitely understand but is that what you had recommended for this coffee tutorial? For example your menu code was this, so I wanted to make mine work the same: <!-- MENU --> <li><a href="/shop/coffee/">Coffee</a></li> <li><a href="/shop/goodies/">Goodies</a></li> <li><a href="/shop/sales/">Sales</a></li> <li><a href="/wishlist.php">Wish List</a></li> <li><a href="/cart.php">Cart</a></li> <!-- END MENU --> Link to comment Share on other sites More sharing options...
michaelnwani Posted March 14, 2012 Author Share Posted March 14, 2012 You are doing the right thing here by putting the /html/ in front links, images and css references. It was what Larry was instructing you to do in the post. This is coffee shop right, which php page is this stuff running of, then i can see why you need that /html/ folder before things? Yeah it is, I'm just trying to make sure how to set up everything for it to work perfectly. I don't think I'm supposed to have /html/ in that header information even though that makes it work, although my file setup I thought was correct. For instance when I click on one of those links after inputting /html/, the url doesn't come up as "/shop/whatever" anymore, instead it comes up as "/html/whatever", and I think that's conflicting with the goal and purpose of the .htaccess: <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> Link to comment Share on other sites More sharing options...
Larry Posted March 14, 2012 Share Posted March 14, 2012 You are DEFINITELY supposed to have '/html/' in the header (i.e., in the references to links, CSS, and images). YES. DEFINITELY. You also need to add 'html/' at the front of each rule in the .htaccess file (after the ^). The problem isn't that the use of /html/ is breaking the .htaccess file, it's that you haven't fixed the .htaccess file to be correct for the use of /html/. Link to comment Share on other sites More sharing options...
michaelnwani Posted March 14, 2012 Author Share Posted March 14, 2012 You are DEFINITELY supposed to have '/html/' in the header (i.e., in the references to links, CSS, and images). YES. DEFINITELY. You also need to add 'html/' at the front of each rule in the .htaccess file (after the ^). The problem isn't that the use of /html/ is breaking the .htaccess file, it's that you haven't fixed the .htaccess file to be correct for the use of /html/. Thank you, I modified almost everything by putting a "/html/" infront of links and such and they seem to work now, but I have a problem with displaying product images now. On the home page, where Sale Items is listed to the right, the four pictures won't come up, and no picture displays when I click on the link to Sales for example. I also put a "html/" in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on # For sales: RewriteRule ^html/shop/sales/?$ sales.php # For the primary categories: RewriteRule ^html/shop/([A-Za-z\+]+)/?$ shop.php?type=$1 # For specific products: RewriteRule ^html/browse/([A-Za-z\+\-]+)/([A-Za-z\+\-]+)/([0-9]+)$ browse.php?type=$1&category=$2&id=$3 # For HTTPS pages: RewriteCond %{HTTPS} off RewriteRule ^html/(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L] </IfModule> Link to comment Share on other sites More sharing options...
Larry Posted March 14, 2012 Share Posted March 14, 2012 Thank you, I modified almost everything by putting a "/html/" infront of links and such and they seem to work now, but I have a problem with displaying product images now. On the home page, where Sale Items is listed to the right, the four pictures won't come up, and no picture displays when I click on the link to Sales for example. Okay. Then you'll need to correct the applicable HTML so that it includes /html/ in the references to those images. Link to comment Share on other sites More sharing options...
Recommended Posts