Reputation: 431
Our site uses custom locales. We save the locale a user selects in a cookie. How would I add to my htaccess file to accomplish redirecting to the proper locale based on the cookie? Our locales end up pre-pending /dallas, /fort-worth , /plano
to the urls.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
Upvotes: 0
Views: 272
Reputation: 26153
Suppose, you set cookie locale=value Then write .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} locale=([^;]+) [NC]
RewriteRule ^(.*)$ /%1/index.php?p=$1 [NC,L,QSA]
i.e. www.examle.com/smtng.html => www.examle.com/value/index.php?p=smtng.html
Upvotes: 1