mod_rewrite: Please explain this to me...
I've been using mod_rewrite forever and thought I fully understood how it works. But apparently, I don't.
I want to do something very simple. I want to rewrite a URL such as this: Code:
http://www.somedomain.com/pages/A1234 Code:
http://www.somedomain.com/cgi-bin/showpage.cgi?page=A1234 Code:
RewriteCond %{REQUEST_URI} ^/pages/[a-zA-Z0-9]+$ Code:
RewriteCond %{REQUEST_URI} ^/pages/[a-zA-Z0-9]+$ |
Perhaps it has something to do with how the regexp is parsed? I stared blankly at this for 10 minutes:
http://httpd.apache.org/docs/2.4/rew...tro.html#regex Also: Quote:
Code:
RewriteRule ^/pages/(.*)$ /cgi-bin/showpage.cgi\?page=$1 I think this image explains the logics, or sequence of parsing: http://httpd.apache.org/docs/2.4/ima...references.png |
Quote:
|
In the example, view$ is used. That's why I thought (.*)$ was ambivalent.
Anyway, your 1st attempt seems at a first glance to set the pattern to /pages/pages/whatever and not /pages/whatever. The condition is ALREADY that you're getting requests to /pages/whatever.. I'm not sure exactly for what reason it fails, but it is easy to see that it is incorrect. The pattern in Rewriterule doesn't match anything. That is, Code:
RewriteRule ^/pages/(.*)$ /cgi-bin/showpage.cgi\?page=$1 |
Quote:
Code:
RewriteRule ^pages/(.*)$ /cgi-bin/showpage.cgi\?page=$1 |
All times are GMT -5. The time now is 02:28 PM. |