Mobile app version of vmapp.org
Login or Join
Martha676

: Managing redirections of 2 domains at CloudFlare for the same site Let's say I have these two domains: example.com.uy example.uy My goal is to set a proper domain's forward according to SEO

@Martha676

Posted in: #301Redirect #Cloudflare #DomainForwarding #Domains #MultipleDomains

Let's say I have these two domains:


example.com.uy
example.uy


My goal is to set a proper domain's forward according to SEO best practices using a 301 Redirect, in order to enforce my users to be always browsing my site at example.com.uy, even when they come from example.uy and keeping the rest of the URL just like /cat/item/1?qwe=rty.

I'm using CloudFlare with their free package, their Page Rules seems to be what I need but I can't figure out how to properly set the forwarding. Perhaps I need to configure something at my domain registrar panel as well.

An example of the kind of redirection I want to achieve is:

example.uy/cat/item/1?qwe=rty>http://www.example.com.uy/cat/item/1?qwe=rty

Sub domain example:
shop.example.uy/cat/item/1?qwe=rty>http://shop.example.com.uy/cat/item/1?qwe=rty
I have tried:


example.uy/*
Forwarding to: www.example.com.uy/ Forwarding type: 302 Temporary


Sadly this is without success, because my .uy domain has no settings yet, simply because I don't know if I should use the same data I've used previously for .com.uy.

So the actual state is:

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Martha676

2 Comments

Sorted by latest first Latest Oldest Best

 

@Debbie626

I don't think you can do that with page rules, or at least not on the free plan. You can use a htaccess/vhost server side rule though (you may or may not need to include RewriteEngine On depending on if it's on already in htaccess)

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?example.uy$ [NC]
RewriteRule ^(.*)$ "https://www.example.com.uy/" [R=301,L]


You can also do it script side, here is how in PHP:

header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
header('Location: ' . str_replace(array('&', "n", "r"), array('&', '', ''), 'www.example.uy' . $_SERVER['REQUEST_URI']));

10% popularity Vote Up Vote Down


 

@Nimeshi995

The way that I do is, add the two domains to cloudflare, redicted it normally to the hosting.
On the hosting cpanel, add both domains, and set on cpanel that this site redirect permanent to your main site, so if any day has to change something, is only on the web provider end.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme