Tengo esta clase que reescribe las url amigables.
Class.seo.php
Código PHP :
<?php class SEO { /* Method to replace characters not accepted in URLs */ function scapeURL ($text) { // Tranformamos todo a minusculas $text = strtolower($text); //Rememplazamos caracteres especiales latinos $find = array('á', 'é', 'í', 'ó', 'ú', 'ñ'); $repl = array('a', 'e', 'i', 'o', 'u', 'n'); $text = str_replace ($find, $repl, $text); // Añaadimos los guiones $find = array(' ', '&', '\r\n', '\n', '+'); $text = str_replace ($find, '-', $text); // Eliminamos y Reemplazamos demás caracteres especiales $find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/'); $repl = array('-', '-', '-'); $text = preg_replace ($find, $repl, $text); return $text; } /* Make rich links */ function categoria ($categoria_id) { $scape_categoria_id = $this->scapeURL($categoria_id); $url = 'http://127.0.0.1/productos/'.$scape_categoria_id.'.html'; return $url; } function subcategoria ($subcategoria_id) { $scape_subcategoria_id = $this->scapeURL($subcategoria_id); $url = 'http://127.0.0.1/productos/'.$scape_subcategoria_id.'.html'; return $url; } function nombre ($nombre) { $scape_nombre = $this->scapeURL($nombre); $url = 'http://127.0.0.1/productos/'.$scape_nombre.'.html'; return $url; } /* } class Redirect extends SEO { /* Redirects URL */ function categoryProductUrl() { //Get URL $redirected_url = $this->getCategoryProductUrl(); //301 Redirection if ("'http://127.0.0.1/" . $_SERVER['REQUEST_URI'] != $redirected_url) { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirected_url); exit(); } } /* Get keyword-rich URL */ function getCategoryProductUrl() { //Get id and category product $categoria_id = $_GET['categoria_id']; $subcategoria_id = $_GET['subcategoria_id']; $nombre = $_GET['nombre']; /* If you have a database */ $categoria_id = ""; $subcategoria_id = ""; $nombre = ""; //Keyword-rich URL $url = $this->categoria($categoria_id, $subcategoria_id, $nombre); return $url; } /* Remove index.php using 301 redirection */ function removeIndexUrl() { //if the request contains index.php redirect if (preg_match('#(.*)index\.(html|php)$#', $_SERVER['REQUEST_URI'], $captures)) { // 301 redirection header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $captures[1]); } } } ?>
Que pasa, al hacer click sobre la url, si me cambia el link, es decir:
127.0.0.1/productos/subcategoria.php?categoria_id=Cannulated Screws
127.0.0.1/productos/cannulated-screws.html
pero no me arroja resultados, es decir, la pagina en blanco.
en mi archivo htaccess tengo esto
Código :
Options +FollowSymlinks RewriteEngine On RewriteRule ^categoria.html categoria.php RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule . - [L] RewriteRule ^(.*)\.html$ subcategoria.php?categoria_id=$1 [L] RewriteRule ^(.*)\.html$ producto.php?subcategoria_id=$1 [L] RewriteRule ^(.*)\.html$ detalle.php?nombre=$1 [L] <files .htaccess> order allow,deny deny from all </files>
Tengo una semana buscandole la solucion pero no la encuentro y no veo el porque no me muestra los resultados.
Espero que me ayuden porque ya me estoy halando los pelos de la nariz
Gracias de antemano!!!