Forum Moderators: phranque
RewriteRule ^parts/([^/]*)/?$ /manufacturer.php?id=$1 [L]
/? means that two different URLs will be able to serve the same content. Do not promote Duplicate Content on your site. Allow only the URL without slash to serve content. Redirect requests "with slash" to URL "without URL". * in ([^/]*)/ allows a request for example.com// with a double slash to be valid. You do not want that. You need ([^/.]+)$ or similar. [edited by: engine at 7:41 am (utc) on Sep 23, 2011]
[edit reason] fixed code [/edit]
Using /? means that two different URLs will be able to serve the same content. Do not promote Duplicate Content on your site. Allow only the URL without slash to serve content. Redirect requests "with slash" to URL "without URL".
The * in ([^/]*)/ allows a request for example.com// with a double slash to be valid. You do not want that. You need ^([^/.]+)$ or similar.
I've tried that, but get a page not found error.
And no wonder, because it's looking for a page with the literal ^ character in the middle.
In RegEx, the caret has special meaning in two contexts. At the very beginning of an expression it means "starts with...". As the first character in grouping brackets, it means "does not include". Everywhere else it is a literal ^.
Since you are rewriting rather than redirecting, and not capturing the /, at least two different places might end up showing the content of /manufacturer.php.
Btw, if you're taking the entire query string and dumping it onto the visible url, I'm not sure how search-engine-friendly it's going to end up. How long are the queries?
The code is almost right. Delete the second of three carets.
Rewording for clarity.
Redirect URL requests with parameters arriving from outside, taking the query string value (not the name) and appending it to the end of the new URL.
Browser then makes new URL request.
Rewrite this new URL request such that is it internally mapped to a server filepath and file with appended parameters to serve the content.
The user gets the page they originally asked for but without a messy query string in the address bar. Links on the site should be amended to point to the URL form that does not have a query string.
Yes, I see that rewrite would be correct, not redirect.
Rewording for clarity.
At least 99% of all the explanations about mod_rewrite that I have ever read outside WebmasterWorld, explain how it works "exactly backwards".
RewriteRule that detects requests with spaces and then rewrites (that's rewrite, not redirect) those requests to a special PHP script. ^([^\s%20]+) means "not a space, not a % character, not the digit 2 or the digit 0". Not exactly what you intended.