Coutry redirect on landing home page of site with TLD awareness

Permalink Browser Info Environment
Hi, i have been trying to get the country redirect to work but we are faced with a problem and this may be due to the way our site is structured please help.

To save on management time all our TLDs point to the same root folder on our web server we will be delivering certain page content based on the TLD so .co.uk will get certain different page content blocks than lets say .mu or .us, i hope this is clear.

On our home page which of course all our TLDs see i have added the country redirect block to the index.php page and stated that any person viewing from my location( Mauritius ) will get forwarded to the .de site (only for testing as our .MU domain hasn't been configured yet).

i can see that the redirect is trying to happen but this happens

"The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies."

is there any way to switch off the country redirect for any other TLD other than the .com and also have the ability to allow the user to override the country redirect so they can see the .com without being redirected if they want to.

I hope this question is clear!!!

Regards
Chris

Type: Discussion
Status: New
cghrmauritius
View Replies:
cghrmauritius replied on at Permalink Reply
cghrmauritius
Have managed to work in a code enhancement to the jb_country_redirect/models/redirect.php not sure if its the right place but it does work.

public static function redirect($country, $url, $except = null)
   {   
      $urlStr = "http://".$_SERVER["SERVER_NAME"]."/";
      $tld = self::get_tld_from_url($urlStr);
      if($tld == "com"){
         self::_lookup();
         $matches = self::countryMatches($country, $except);
         if( $matches )
         {
            //if( !@header("Location: $url") )
            if( headers_sent() )
            {
               print('<script type="text/javascript"> window.location = "'.$url.'"; </script>');
            }
            else{


if anyone has a better idea please let me know.
jb1 replied on at Permalink Reply
jb1
Hi Chris,
Your solution looks like a good workaround. I'd do the same or place similar code in the controller.php. A couple things to be aware of:
- if another addon is installed which also hooks into the same event (when the page loads), such as the multi-site/domain, c5 caching can get in the way. If suggest turning off c5 caching for that page.
- the browser can also cache DNS redirects, so if the page continues to redirect even when you don't want it to, try clearing your browser temp files (this is fairly rare).

Hope this helps.

JB
cghrmauritius replied on at Permalink Reply
cghrmauritius
Hi thanks jb for your response, how do you think i should go about allowing a user to actually view the .com without being redirected, maybe a session var or a cookie altered by a button a bit like google does, any ideas please I'm not sure what the best approach through c5 would be as I'm fairly new to c5 and still learning it the hard way.

Also would this functionality not be a good idea to include into your package as i am prity sure a lot of users would need to do this when country detecting and redirecting?

Kind regards

Chris Robinson, impactChoice.com
jb1 replied on at Permalink Reply
jb1
Hi Chris,
Your existing code is on the right track. Using PHP just check the URL and if the extension is ".com", then don't do any redirecting, otherwise the redirection will occur as normal.

This is the first time anyone has asked for this type of feature for the Country Redirect add-on. The intention is this block is placed on the home page and you have multiple country-specific pages underneath which the user is redirected to. So the top level home page doesn't really need anything else other than the Country Redirect block.

JB

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.