Forum Moderators: phranque
I have this regexp:
^([^/]+)/(.+)
But I want to track a question mark, instead of a slash:
^([^?]+)\?(.+)
Because the url is something like:
[mysite.com...]
and not:
[mysite.com...]
(what I can accomplish with javascript, but would be unnecessary brute force if I manage mod_rewrite to see the "?" as a regular character)
The problem is that the backslash doesn´t seem to work, I don´t understand why. Is there a special way to escape the "?" in mod_rewrite? Maybe use the hex equivalent, or sth?
Thanks
André
I think the problem is mod_rewrite (Apache) will not see the ? (or query string) in the RewriteRule. The query string will only be parsed in a condition.
RewriteCond %{QUERY_STRING} ^regex here$
RewriteRule . /Redirect-Action [R=301,L]
Without a specific example, I cannot give you a specific solution.
Hope this gives you some direction.
Justin
Thanks a lot for the help, man.
Now I managed him to see the query string, but can´t make him remember what would be %2.
Here´s the code:
RewriteEngine on
RewriteCond %{REQUEST_URI}!\.(cgi¦css¦gif¦jpg)$
RewriteCond %{HTTP_HOST} ^www\.([^\.]+)\.mysite\.com
RewriteCond %{QUERY_STRING} ^(.+)
RewriteRule ^(.+) /home/mysite/www/scripts/page.cgi?vendor=%1\§ion=$1\&%2 [L]
He returns the last () in the query string cond in %1, instead of in %2, as I expected. And %2 doesn´t get nothing. How to overcome this, Justin?
I tried to put the #2 and #3 conditions together, but & and && didn´t worked.
Thanks
André
RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(cgi¦css¦gif¦jpg)$
RewriteCond %{QUERY_STRING}<->%{HTTP_HOST} ^([^<]+)<->(www\.)?([^\.]+)\.mysite\.com
RewriteRule (.+) /home/mysite/www/scripts/page.cgi?vendor=%3§ion=$1&%1 [L]
Jim