Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento redirection with htaccess

I want to redirect example.com to example.au,but at the same time i want to exclude example.com/admin from redirection. Is it possible if yes please provide any rewrite rules.Any help would be appreciated.

Code:

RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]

#RewriteRule .* index.php [L]

RewriteRule ^(.*)$ www.example.com.au/$1 [R=301,L]
RewriteRule !^(admin/.*)$ www.example.com.au/$1 [R=301,L]
like image 864
vic Avatar asked Dec 01 '25 02:12

vic


1 Answers

You can use following .htaccess redirection code for access admin

GeoIPEnable On 
ReWriteEngine On  
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} IN$   //IN is the country code where you want to redirect
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_URI} !admin 
RewriteCond %{REQUEST_URI} !index.php [NC]     //admin keywords
RewriteRule ^ http://www.domain.in [R=301,L]  //redirection url

In the above example admin and index.php are the keywords for accessing admin

RewriteCond %{REQUEST_URI} !admin 
RewriteCond %{REQUEST_URI} !index.php [NC] 

It means redirect to specific url in INDIA,only when the current url doesn't have the above keywords(all admin modules only have these keywords).

It would be help you. I'm also using the above same code for my store

All the best

EDIT : You can refer the following threads too for getting some more details

Some admin modules redirect to frontend

Magento redirection with htaccess based on country wise

like image 90
DRAJI Avatar answered Dec 03 '25 15:12

DRAJI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!