Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action ('wp_loaded', 'my_redirect_function');
- function my_redirect_function() {
- $ip = '';
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
- {
- $ip=$_SERVER['HTTP_CLIENT_IP'];
- }
- elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
- {
- $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- else
- {
- $ip=$_SERVER['REMOTE_ADDR'];
- }
- $country = file_get_contents('http://geoip.maxmind.com/a?l=6QT6fNSdtMVw&i='.$ip);
- if( $country == 'IE' ) {
- wp_redirect( get_bloginfo('url') . "/ie/" );
- exit;
- }
- }
- if( $country == 'IE' ) {
- if( $country == 'IE' && substr( $_SERVER['REQUEST_URI'], 0, 4 ) == '/ie/' ) {
Add Comment
Please, Sign In to add comment