View Single Post
Old 10-10-2008, 10:45 AM   #3 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Well, first of all, $1, $2, ..., $n are references to the previously captured groups (stuff between paranthesis, in the order they were created). Second of all, in regex, ^ delimits the beginning of a regular expression, whereas $ represents the end of it. Thirdly, you need to tell apache that it needs to do a URL rewrite, by prefixing rewrite rules with "RewriteRule". So, your rule is wrong right from the beginning of the second line. Here's the correct rule:

Code:
RewriteRule  ^products/([0-9]+)$ cart.php?m=product_list&c=$1 [QSA]
Mod_Rewrite Forums :: Index

Now, about the rules effect. Well, they take effect in the moment you save your .htaccess file. Meaning that you will be able to access http://somesite.com/products/7 after you add that rule to your .htaccess. However, it will not replace your current URLs with the rewritten ones. How should apache know which ones should be left intact and which ones should be rewritten? So yes, you need to manually change all URLs you are rewriting. That's why you have to think about URL rewriting (whether you will ever need it or not) BEFORE the actual coding, so you don't have to do the same thing twice.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
sarmenhb (10-10-2008)