2014-03-13 53 views
3

我想將example.com重定向到example.au,但同時我想從重定向中排除example.com/admin。如果是,請提供任何重寫規則。如有任何幫助,我們將不勝感激。帶htaccess的Magento重定向

代碼:

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] 

回答

1

您可以使用下面的訪問管理

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 

的.htaccess重定向代碼在以上示例admin和index.php是訪問的關鍵字荷蘭國際集團管理

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

這意味着重定向到特定的URL在印度,只有噹噹前URL不具有上述關鍵字(所有管理模塊只有這些關鍵字)。

這將幫助你。我還使用上述相同的代碼爲我的商店

所有最優秀的

編輯:您可以參考以下的線程也爲獲得更多細節

Some admin modules redirect to frontend

Magento redirection with htaccess based on country wise

+0

非常感謝,你救了我!!!!!!!!!!!!!!!! – vic

+0

@vic歡迎 – DRAJI

+0

更多的事情親愛的它表明,它有rediect 301和302. 我檢查它與這個網站redirect-checker.org。 結果: example.com/ 301永久移動 example.com.au 302暫時移動 www.example.com.au/ 200 OK 能否請你告訴我哪裏做的錯誤提前 – vic