Hi....i try to find "CountryDetector::redirect(" in order to set redirection country to subdomain but i can't find it. will you help me to show the example.
You can include an index.php file in root domain vesgeta.com with this code:
<?php
// Start by including CountryDetector class
include( "../src/CountryDetector.class.php" );
$country_code = CountryDetector::getCountryCode();
switch ( $country_code ) {
// Kenya
case 'KE':
header( 'Location: https://ke.vesgeta.com' );
break;
// Tanzania
case 'TZ':
header( 'Location: https://tz.vesgeta.com' );
break;
// Default set to india
default:
header( 'Location: https://in.vesgeta.com' );
}
The code is self explanatory and has default redirect country set to India.
Warning: include(/CountryDetector.class.php): failed to open stream: No such file or directory in /home1/vesgeta/public_html/index redirect.php on line 3
Warning: include(/CountryDetector.class.php): failed to open stream: No such file or directory in /home1/vesgeta/public_html/index redirect.php on line 3
Warning: include(): Failed opening '/CountryDetector.class.php' for inclusion (include_path='.:/opt/php71/lib/php') in /home1/vesgeta/public_html/index redirect.php on line 3
Fatal error: Uncaught Error: Class 'CountryDetector' not found in /home1/vesgeta/public_html/index redirect.php:4 Stack trace: #0 {main} thrown in /home1/vesgeta/public_html/index redirect.php on line 4
The problem is with the path of country detector class. I wrote "../src/CountryDetector.class.php" and it looks up one directory so it might be that the src folder doesn't exists so I suggest you to put the src folder inside the directory you are currently using the script and remove the "../" so it should be
Hi....i try to find "CountryDetector::redirect(" in order to set redirection country to subdomain but i can't find it. will you help me to show the example.
set this three country. tanzania - https://tz.vesgeta.com
Kenya - https://ke.vesgeta.com
India - https://in.vesgeta.com
to save time.
Hi James,
You can include an index.php file in root domain vesgeta.com with this code:
The code is self explanatory and has default redirect country set to India.I hope this helps you.
Is not working. Check it if am doing wrong then correct it bro. help me
Hi James,
The code is just fine, you can see the output of country code for testing by creating an index-test.php with this code:
You can check which country code is accessing your site from this file. Please test this and see the result.
it sho me that error when i use that code
Warning: include(/CountryDetector.class.php): failed to open stream: No such file or directory in /home1/vesgeta/public_html/index redirect.php on line 3
Warning: include(/CountryDetector.class.php): failed to open stream: No such file or directory in /home1/vesgeta/public_html/index redirect.php on line 3
Warning: include(): Failed opening '/CountryDetector.class.php' for inclusion (include_path='.:/opt/php71/lib/php') in /home1/vesgeta/public_html/index redirect.php on line 3
Fatal error: Uncaught Error: Class 'CountryDetector' not found in /home1/vesgeta/public_html/index redirect.php:4 Stack trace: #0 {main} thrown in /home1/vesgeta/public_html/index redirect.php on line 4
Hi James,
The problem is with the path of country detector class. I wrote "../src/CountryDetector.class.php" and it looks up one directory so it might be that the src folder doesn't exists so I suggest you to put the src folder inside the directory you are currently using the script and remove the "../" so it should be
I hope this will help you.