Announcements

Welcome to Servikus Tutorials Area! You will find a ton of useful tutorials in our tutorial area. We hope that you will find them useful! If you want custom tutorial created, please let us know and we will create it for you!

Recent Posts

301 Redirection in from old to a new domain (.htaccess)

Posted on 21/01/2022 by

For instance, you have two domains – testingaddondomain.com (old domain) and addondomain.com (new domain). You want to make that, once you type the old domain, a new domain appears in the browser, and that it shows the content of the old domain.

If you don’t have a directory and new domain on your account, you can add it as an addon domain. You can check our previous tutorial on how to add it.

Here is how you can do it if you already have the domains added to your cPanel account.

1. Log in to your cPanel account, then to File Manager. Navigate to the directory of the domain (in this case testingaddondomain.com) which you wish to redirect to a new domain.

2. Click on the Settings button and make sure that you check the box “Show Hidden Files”, so you can move all the files.

3. Click Select All, then click Move. You will need to enter a path to the directory where your new domain is located (in this case it’s home/addondomain.com). Click Move Files.

4. Once you do that, the directory will remain empty. You need to create a new file called .htaccess. Press the button in the top left corner to create it.

Note: Don’t forget the dot in the name, as the file will not work properly without it.

5. When you have created the file, click on it, then click on the Edit button from the top menu. The system will ask you to confirm and press Edit one more time.

6. Paste the following code into that file, then replace the olddomain.com and newdomain.com with your domain names, then save the file.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS_HOST} ^olddomain.com$ [OR]
  RewriteCond %{HTTPS_HOST} ^www.olddomain.com$
  RewriteRule (.*)$ https://www.newdomain.com/$1 [R=301,L]
</IfModule>

7. Next, you need to find the name of your website’s database to make a few changes. To do that, navigate to the directory where you moved the website’s content. Find the wp_config.php file and click View. You will find your database name next to this parameter ‘DB_NAME’ (in this case celebfre_wp746). Also, you can find your table prefix in this file if you scroll down. You will need it for the next step to edit the particular table, tableprefix_options. Usually, the prefix is wp_. In this case, it is

$table_prefix = ‘wptz_’

8. Go back to the cPanel dashboard and find phpMyAdmin. Find your database by its name and select it. Find the table called wptz_options in this case (most of the time it is wp_options if don’t know your table prefix) and click on the name or the ‘+’ to expand it. You need to change the URLs for siteurl and home option_values. You will need to change one option at a time.

9. To make a change, click Edit, put the URL of your new domain instead of an old one (in this case https://addondomain.com) and click Go. Do the same for the home option.

10. Check if your redirection works by typing the old domain to the browser (it should show the website and the new domain) and you are set!

In case you are having difficulties with making a redirection, you can always reach out to Servikus’ support to help you out with it.

============================================================================

Leave a Reply

Your email address will not be published.


*



Servikus

© Servikus
Terms of Service