New Rule

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 21 Jun 2016, 16:40

New Rule

22 Jun 2016, 18:53

So I created a map file with my country names as such;

br br
ca ca
gr gr

I am hoping to be able to check this map file (after all my other rules) and if a pattern matches then append the value to the querystring (in addition to any other values that may already be on the querystring).

For example currently:

http://[domain].com/somepage

would produce a match for http://[domain].com/somepage.asp

At the end of the script, i have added:

RewriteMap evcountry txt:ev_countrydomains.txt
RewriteCond ${evcountry:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^([^?/]+)\/(.*)$ /[^.]+\.[^.]+lan=$1{evcountry:$1} [NC,L,QSA]

However this doesnt seem to work. I am trying to say if a user enters:

http://[domain].com/br/somepage

it will match the map file, so take a previous fule and just add "lan=br" to the querystring (in addition to any other parameters).

if a user just does http://[domain].com/somepage... it will produce no match and hence will just execute rules above this.

Any help in constructing a rule would be much appreciated.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: New Rule

29 Jun 2016, 07:11

Hello.

To tell more I need to see your whole .htaccess, but please try this first:
Code: Select all
RewriteMap evcountry txt:ev_countrydomains.txt
RewriteCond ${evcountry:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(\w{2})(/.*) $2\?lan=$1 [NC,L,QSA]


or this depending on your .htaccess context level:

Code: Select all
RewriteMap evcountry txt:ev_countrydomains.txt
RewriteCond ${evcountry:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^/(\w{2})(/.*) $2\?lan=$1 [NC,L,QSA]


And if country code is always two character long and you don't have real two character folders you can omit map file part:


Code: Select all
RewriteRule ^(\w{2})(/.*) $2\?lan=$1 [NC,L,QSA]

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 21 guests