Redirect
You can redirect the traffic of a specific URL to another one under the Page Rules section. For this purpose, go to the Page Rules section of your user panel under the CDN service and click on Add New Rule.
Enter the URL in the new window (such as www.example.com) and select the Redirect option from the drop-down menu.
You need to activate the status to choose one of the codes 301, 302, or 307 for your address.
Code 301 (permanent redirect): This code is used when the address permanently changes to another one. This code shows the search engines that the new URL is replacing the old one permanently. If you want to keep using the old URL, you need to use the 302 redirect code (temporary redirect). For example, when the domain has changed, you want the visitors to access the website through the old link.
Code 302: This code is used for temporary redirects meaning that the content is found but in a different link. You can use this code when you want to temporarily redirect the visitors from the previous URL to the new one. The search engines would not change the URL with this code.
Code 307: This code is similar to 302, the only difference being that the HTTP 1/1 redirection uses code 307 instead of 302. This code guarantees that the method will not change during the redirection (HTTP 1/0 uses code 302 to redirect and sometimes needs to change the process from POST to GET).
Enter the domain you want your redirection to be in the URL section and click on Create.
Advanced Redirect Settings
Redirection can happen through the usual settings of the Page Rules. However, if the source URL has more than one address for the main domain, it would not affect redirecting visitors. For example, when the redirection is from
sample.com
To
newsample.com
The requests for the following page
sample.com/example.html
Will still be redirected to
newsample.com
While the ideal redirection would be to
newsample.com/example.html
To prevent this, you need to use variables in the page rule. Go to the Page Rules section of your account under the CDN section and click on Add a New Rule.
Enter the URL and then click on + to add the rule. On the opened window, click on Redirect and choose one of the codes 301, 302, or 307.
Then, enter the URL you want your traffic to be redirected to. Please note that you can use * for placing variables anywhere in the URL. For example:
Sample.com/*
*.Sample.com
Sample.com/New/*.jpg
The query string will not be redirected from the source address to the destination one in the above URLs.
The destination address must have $ and a number.
Newsample.com/$1
$1.Newsample.com
Also, an address can have more than one variable.
*.Sample.com/*
In this case, $1 points to the first variable and $2 points to the second. Similarly, the $n points to the nth variable.
$1.newsample.com/$2
Once you have configured your settings, click on Add a New Rule to save and apply the changes.
Now, the user that opens the following website,
Sample.com/example.html
Will be redirected to the following one,
Newsample.com/example.html