Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- mod rewrite prob


andreasfriedrich - 2:53 pm on Oct 22, 2002 (gmt 0)


You cannot access the query string in a RewriteRule. You would need to use RewriteCond [httpd.apache.org] %{QUERY_STRING} for that. RewriteCond defines a condition. The following RewriteRule is only used if this condition is met and the rewrite rule itself matches.

Quite frequently you use RewriteCond not for the condition it allows you to specify but for gaining access to and matching certain parts of a whole lot of server variables.

RewriteCond %{QUERY_STRING} id=([^&]+) 
RewriteRule ^widgets/(.*)\.htm$ /solar.php?pg=$1&cat=widgets&id=%1

RewriteCond takes the QUERY_STRING and tries to match 'id=' followed by one or more characters that are not &. Those characters are stored %1.

You will need an additional RewriteRule (like the one in my previous post) to handle cases where there is no 'id=' in the query string since you made that a condition by specifying the RewriteCond.

Andreas


Thread source:: http://www.webmasterworld.com/apache/145.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com