Embed presentation
![Htaccess - Complex redirections Cristina Martin, Web developer [email_address] epoint.ro: Epoint Web Solutions](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-1-2048.jpg&f=jpg&w=240)





![.htaccess - First case RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^RO$ RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{HTTP_COOKIE} !^.*Language.*$ [NC] RewriteCond %{HTTP_COOKIE} !^.*Country.*$ [NC] RewriteRule ^(.*)$ /index.php?id=81&L=2 [L]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-7-2048.jpg&f=jpg&w=240)
![.htaccess – First case [NC] (no-case) - This makes the test case-insensitive - differences between 'A-Z' and 'a-z' are ignored when is match with the current URL. [L] (last rule) - Stop the rewriting process here and don't apply any more rewrite rules](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-8-2048.jpg&f=jpg&w=240)

![.htaccess – Second case RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{HTTP_COOKIE} Language=([^;]+) [NC] RewriteRule ^(.*)$ /index.php?L=%1 [NC,C] RewriteCond %{HTTP_COOKIE} Country=([^;]+) [NC] RewriteRule ^(.*)$ /index.php?id=%1%2 [NC,L,QSA]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-10-2048.jpg&f=jpg&w=240)
![.htaccess – Second case [C] (chained with next rule) - Chains the current rule with the next rule. If a rule matches, then the rule is processed further, but if the rule does not match, then all the following chained rule will not be processed [QSA] (query string append) - Forces the rewriting engine to add a query string part of the existing string, instead of replacing it.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-11-2048.jpg&f=jpg&w=240)



The document discusses using .htaccess files and cookies to implement country and language redirection on a website based on the user's geographic location or previously selected preferences. It provides code examples for redirecting users based on their IP address determined country to the corresponding section, or allowing them to access a preferred section based on language and country cookies set on previous visits. Resources on geoIP databases and .htaccess modrewrite rules are also referenced.
![Htaccess - Complex redirections Cristina Martin, Web developer [email_address] epoint.ro: Epoint Web Solutions](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-1-2048.jpg&f=jpg&w=240)





![.htaccess - First case RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^RO$ RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{HTTP_COOKIE} !^.*Language.*$ [NC] RewriteCond %{HTTP_COOKIE} !^.*Country.*$ [NC] RewriteRule ^(.*)$ /index.php?id=81&L=2 [L]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-7-2048.jpg&f=jpg&w=240)
![.htaccess – First case [NC] (no-case) - This makes the test case-insensitive - differences between 'A-Z' and 'a-z' are ignored when is match with the current URL. [L] (last rule) - Stop the rewriting process here and don't apply any more rewrite rules](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-8-2048.jpg&f=jpg&w=240)

![.htaccess – Second case RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{HTTP_COOKIE} Language=([^;]+) [NC] RewriteRule ^(.*)$ /index.php?L=%1 [NC,C] RewriteCond %{HTTP_COOKIE} Country=([^;]+) [NC] RewriteRule ^(.*)$ /index.php?id=%1%2 [NC,L,QSA]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-10-2048.jpg&f=jpg&w=240)
![.htaccess – Second case [C] (chained with next rule) - Chains the current rule with the next rule. If a rule matches, then the rule is processed further, but if the rule does not match, then all the following chained rule will not be processed [QSA] (query string append) - Forces the rewriting engine to add a query string part of the existing string, instead of replacing it.](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fprezentare-htaccess-en2a-110516024151-phpapp02%2f75%2fHtaccess-with-Cookies-11-2048.jpg&f=jpg&w=240)


