url rewriting - URL optimization with php -
i've been trying several ways optimize url result when db of site consulted, changing .htaccess adding php @ top, , other ways include both, nothing happens, there many ways around web i'm feeling unlucky , kind of powerless trying implement of ways, can't make work.
the products catalog organized in popular way in mysql db, nothing revolutionary or unique, $_get method , that's all, got department, category or product user clicks. can give me this? kind of basic advanced developers not one. in advance time!
the .htaccess code here:
<ifmodule mod_rewrite.c> rewriteengine on rewriterule testpage\.html http://www.google.com [r] rewriterule ^catalog/(\d+) catalogo.php?cat=$1 [l,nc] rewriterule ^department/(\d+) catalogo.php?dpto=$1 [l,nc] rewriterule ^producto/(\d+) producto.php?id=$1 [l,nc] </ifmodule>
rewriteengine on rewriterule ^catalog/(\d+) catalog.php?cat=$1 [l,nc]
that basic regex match category (\d+) - digit - , map category.php?cat= $1 means plug in number found in first parenthesis (6) example.
rewriterule ^department/(\d+) catalog.php?dpt=$1 [l,nc]
that work department.
you can place whatever in url, should decide more specific -
rewriterule ^catalog/department/(\d+) catalog.php?dpt=$1 [l,nc] rewriterule ^catalog/category/(\d+) catalog.php?cat=$1 [l,nc]
remember, rewriteengine on
must in .htaccess before rules set.
typically, whole thing wrapped in conditional, so:
<ifmodule mod_rewrite.c> rewriteengine on rewriterule ^catalog/department/(\d+) catalog.php?dpt=$1 [l,nc] rewriterule ^catalog/category/(\d+) catalog.php?cat=$1 [l,nc] </ifmodule>
Comments
Post a Comment