Forum Moderators: phranque
Again, thank you guys for all your help and support.
In the request
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /dir/\?page=([0-9]+)\ HTTP/
So putting this into English, I get, "If there is a request from the browser (I'm not sure why capital letters A-Z here? I get the next part, just pattern matching what the page request is, except I don't understand why there is a backslash at the end, but not important) AND if it is an HTTP request (the HTTP/ part), then perform the next rule."
The only part I don't get looking at this logically is the ^[A-Z]+\ I could see doing it without it, but I don't understand what this is (especially considering since I don't have any capital letters in my URI).
Thanks a bunch!
CWebguy
[edited by: CWebguy at 8:24 pm (utc) on Mar. 11, 2009]
It is exactly what your browser requests from the server as in:
GET /somepage.php?query=somevalue HTTP/1.1 So
[A-Z]{3,9} matches the method, in this case the GET. In your case you have [A-Z]+ which does the same job, but is not so efficient. The
HTTP/ matches all versions of HTTP request, so that (hopefully) you won't have to change your code when HTTP/2.x arrives. Literal spaces and literal question marks are escaped as already shown.
And the backslash after the [A-Z] and pattern matching, what's that there for?
Mucho gracias
Note: I will try out that extension, thanks.
I've done some header stuff with PHP so I know what you are saying. thanks.
[edited by: CWebguy at 8:42 pm (utc) on Mar. 11, 2009]
No. Neither of those are valid constructs for matching the pattern here.
Did you mean .* instead of * here? That would work, but there is no need to put .* on the end of an unanchored pattern.
As for your HTTP/ ? pattern, that would match HTTP/ followed by a space followed by a question mark. That would never happen in a real request.
*** And the backslash after the [A-Z] and pattern matching, what's that there for? ***
Literal spaces and literal question marks are escaped with a preceding backslash as already shown.
[edited by: g1smd at 9:01 pm (utc) on Mar. 11, 2009]
mod_rewrite is a very powerful tool, but as with any powerful tool, it is best to learn how to use it before relying on it or risking the (potentially severe) damage it can do in untrained hands. You can accomplish a lot with it and it's available at no extra charge on all competitive hosting accounts, but the "cost of admission" is several days (at least) in research time.
Jim