Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/06/2016, 17:27
Avatar de Fernarey1810
Fernarey1810
 
Fecha de Ingreso: noviembre-2008
Mensajes: 214
Antigüedad: 15 años, 5 meses
Puntos: 1
Porque me da este error Not Found

Not Found
The requested URL /product.php was not found on this server.


Archivo product.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. require_once 'include/url_redirect.inc.php';
  4.  
  5. fix_category_product_url();
  6.  
  7. echo 'You have selected product #' . $_GET['product_id'] .
  8.      ' from category #' . $_GET['category_id'];
  9.  
  10. ?>

Archivo url_redirect.inc.php
Código PHP:
Ver original
  1. <?php
  2.  
  3. define('SITE_DOMAIN', 'localhost/Apache/Capitulo4');
  4.  
  5. $GLOBALS['products'] = array
  6.       ("45" => "Belt Sander",
  7.        "31" => "Link Juice",
  8.        "42" => "AJAX PHP Book");
  9. $GLOBALS['categories'] = array
  10.       ("12" => "Carpenter's Tools",
  11.         "6" => "SEO Toolbox",
  12.         "2" => "Friend's Shed");
  13.  
  14. function fix_category_product_url()
  15. {  
  16.  
  17.   $proper_url = get_proper_category_product_url();
  18.  
  19.   if (SITE_DOMAIN . $_SERVER['REQUEST_URI'] != $proper_url)
  20.   {
  21.     header('HTTP/1.1 301 Moved Permanently');
  22.     header('Location: ' . $proper_url);
  23.     exit();    
  24.   }
  25. }
  26.  
  27.  
  28. function get_proper_category_product_url()
  29. {
  30.  
  31.   $product_id = $_GET['product_id'];
  32.   $category_id = $_GET['category_id'];
  33.  
  34.   $product_name = $GLOBALS['products'][$product_id];
  35.   $category_name = $GLOBALS['categories'][$category_id];
  36.  
  37.   $proper_url = make_category_product_url($category_name, $category_id,
  38.                                           $product_name, $product_id);
  39.  
  40.   return $proper_url;
  41. }
  42.  
  43. ?>

Archivo .htaccess

RewriteEngine On

# Rewrite numeric URLs
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$ /product.php?category_id=$1&product_id=$2 [L]

# Rewrite keyword-rich URLs
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$ /product.php?category_id=$1&product_id=$2 [L]