Forum Moderators: phranque
the scenario, i can only use apache.conf, not htaccess:
1) http://example.com/yy/zz/request?request_type=default&country=us
to
[newurl.com...]
2) http://example.com/yy/zz/request?request_type=default&country=japan
to
[newurl.com...]
3) http://example.com/yy/zz/request?request_type=default&country=taiwan
to:
[newurl.com...]
so far, ive tried redirectmatch but couldnt make it.
The closest ive get was with this line:
RewriteRule ^/yy/zz/request\?(.)request_type(.*)$ [newurl.com...]
but for this, im getting this type of redirection: [newurl.com...]
this is not good, im seeing that i have 2 variables, but are separated by the symbol & and couldnīt match it with regular expresions.
Also, i donīt know if i will be any aditional rule.
Can you give me a little piece of your expertise to work it out?
Thanks a lot!
[edited by: jdMorgan at 12:25 am (utc) on June 19, 2009]
[edit reason] example.com [/edit]
RewriteCond %{QUERY_STRING} ^request_type=default&country=us$
RewriteRule ^/yy/zz/request$ http://www.example.com/us/? [R=301,L]
#
RewriteCond %{QUERY_STRING} ^request_type=default&country=japan$
RewriteRule ^/yy/zz/request$ http://www.example.com/jp/? [R=301,L]
#
RewriteCond %{QUERY_STRING} ^request_type=default&country=taiwan$
RewriteRule ^/yy/zz/request$ http://www.example.com/tw/? [R=301,L]
RewriteCond %{QUERY_STRING} ^request_type=default&country=([a-z]+)$
RewriteCond %1>us ^us>([a-z]+)$ [OR]
RewriteCond %1>jp ^japan>([a-z]+)$ [OR]
RewriteCond %1>tw ^taiwan>([a-z]+)$ [OR]
RewriteCond %1>cn ^china>([a-z]+)$ [OR]
RewriteCond %1>vn ^vietnam>([a-z]+)$ [OR]
RewriteCond %1>sg ^singapore>([a-z]+)$ [OR]
RewriteCond %1>th ^thailand>([a-z]+)$
RewriteRule ^/yy/zz/request$ http://www.example.com/%1/? [R=301,L]
The question mark at the end of the substitution URL clears the query string. It will not appear in the redirected URL.
The ">" character in the RewriteConds is arbitrary; It has no special meaning to mod_rewrite or to the regular expressions matching engine, but serves only as a delimiter between the country-match string and the back-referenced country code. I picked it because it is relatively unique and because it implies concatenation.
If you have a huge list of countries, look into using a RewriteMap -- See the Apache mod_rewrite documentation.
Jim
[edit] Corrections as noted below. [/edit]
[edited by: jdMorgan at 10:33 pm (utc) on June 18, 2009]
However, im still facing issues:
For example, in first rule:
RewriteCond %{QUERY_STRING} ^request_type=default&country=us$
RewriteRule ^/yy/zz/request$ http://www.example.com/us/
Im getting a redirect to:
http://www.example.com/?request_type=default&country=us
As you can see, im getting the whole request and the two variables after the URL.
I tryied changing and applying REG expressions, but i think that the "&" characters is bringing me problems.
Any further tip?
And I was thinking.....
Do apache see this "dinamic pages"?
or it must be an absolute, fixed URL page?
Thanks again!