I am having a problem with rewritting the URL using .htaccess, When the URL is something that looks like that original url: http://www.example.com/page.php?id=1&name=test after rewrite: http://www.example.com/page-1-test it works fine
but the manager asked for hyphens instead of spaces so i did this
$name = str_replace(" ", "-", $name);
then i echo $page_name http://www.example.com/page.php?id=2&name=test-some-other-text
so it would look like this http://www.example.com/page-2-test-some-other-text
in the it takes 2-test-some-other-text as the id when i try to $_GET['id'];
and here is my rewrite rule in the .htaccess
RewriteRule page-(.*)-(.*)$ page.php?id=$1&name=$2
RewriteRule page-(\d+)-(.*)$ page.php?id=$1&name=$2this is better control of groups. - Jonespage-(.*)will capture anything afterpage-, it won't stop at the other dash. - Evan Mulawski