need some mod_rewrite help
View Single Post
10-10-2008, 10:45 AM
Join Date: Dec 2007
Location: Bucharest, Romania
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:
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
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.
The Following User Says Thank You to xenon For This Useful Post:
View Public Profile
Send a private message to xenon
Visit xenon's homepage!
Find More Posts by xenon