with, or without, any appended query string and will redirect to the new URL, re-appending any query string (if present).
The question mark is used to show characters that are optional. If you need a literal question mark, then you need to escape it.
glimbeek
1:18 pm on Feb 5, 2010 (gmt 0)
"The question mark is used to show characters that are optional."
I know, but the question mark is in the URL and I don't want it to be in the URL. Hence me putting it their in my example. The URL is made up from the article title and in the title there's a question mark.
So I use RewriteRule ^what-has-happend-now\?/$ http://www.example.com/news/what-has-happend-now/ [R=301,L]
? I tried that, and that doesn't work. I end up with: http://www.example.com/news/what-has-happend-now/?/
Note that the value of "THE_REQUEST" is the client's HTTP request line, exactly as it appears in your raw server access logs. Example:
GET /what-has-happend-now?/ HTTP/1.1
Note also that the question mark at the end of the RewriteRule's substitution URL is NOT a literal question mark. It is a mod_rewrite operator that clears the current query string, and is required.
Because you're dealing with the way that query strings are appended to URLs and the way that Apache handles them, this code looks all wrong. But it's very likely correct.
Finally, note that the word "happened" is miss-spelled consistently as "happend" throughout this thread. We're all assuming that this was intentional.
Jim
glimbeek
8:08 am on Feb 9, 2010 (gmt 0)
The miss spelling of happened is due to my crappy English ;)
Thanks for the explanation jdMorgan, I'll give it a go.