How to Write 301 Redirects Using SiteGround

Written by Ryan

Ryan McPhee is a Small Business Owner, Blogger, Product Manager, and serial entrepreneur. He has a strong passion for helping small business owners build strong foundations for success.

July 12, 2024

How We Earn Income

We may earn a small commission at no extra cost to you from select affiliate links. For more details, please see our affiliate policy here.

Setting up 301 redirects on your SiteGround-hosted website helps manage changes to your site’s URL structure. Redirects help visitors and search engines find the correct pages, preserving your site’s SEO value and overall user experience. This guide will walk you through two methods: using the .htaccess file and SiteGround’s Redirect Console. We’ll cover the benefits of each method and provide detailed, step-by-step instructions for implementation. By the end, you’ll be able to choose the best approach for your needs and successfully set up 301 redirects on your website using SiteGround.

Using .htaccess vs. SiteGround’s Redirect Console

There are two methods you may employ when creating 301 redirects:

  • .htaccess File: This method involves manually editing the .htaccess file in your website’s ‘public_html’ directory to create 301 redirects.
  • Redirect Console: A user-friendly tool within SiteGround’s Site Tools that allows you to set up and manage 301 redirects without editing code.

Choosing Between the Two Methods

Both methods are effective for managing 301 redirects on SiteGround. Your choice depends on your specific needs, technical comfort level, and the complexity of the redirects you must implement.

  • Simplicity vs. Control: The Redirect Console method is the way to go if you prefer a simpler, user-friendly approach. It’s perfect for basic redirects and quick setups. Editing the .htaccess file is recommended for more control and advanced configurations.
  • Frequency of Changes: The Redirect Console is convenient and efficient for occasional redirects. If you regularly update your redirects or require complex rules, the .htaccess file may offer the necessary flexibility.
  • Technical Comfort: Choose the Redirect console if you’re uncomfortable with coding. Use the .htaccess file if you have experience with server configurations and need more advanced options.

Before we dive into the specific steps for each method. Let’s consider the advantages of each:

Advantages of Using the .htaccess File

  • Flexibility: You can create more complex redirect rules, including conditional redirects based on user agents or referrers.
  • Advanced Features: The .htaccess file supports various Apache directives, offering more advanced website management capabilities.
  • Direct Control: Experienced users have complete control over their redirect configurations without relying on an interface.

Advantages of the Redirect Console

  • User-Friendly: The interface is straightforward, making it ideal for those who are uncomfortable editing code.
  • Quick Setup: It streamlines the process, allowing you to set up redirects quickly without worrying about syntax errors.
  • Easy Management: You can easily view, edit, or delete existing redirects from the same console.

Method 1: Using the .htaccess File

The classic and most common method for creating a 301 redirect is the .htaccess File. This method is more robust and recommended. However, you can skip to method two if this process is too technical or confusing.

IMPORTANT: Modifying a website’s .htaccess file without sufficient experience can lead to serious issues, such as site crashes, security risks, and loss of access, potentially disrupting your entire website.

Method 1, Step 1: Access the .htaccess File

  • Log into SiteGround. Go to your SiteGround account and log in using your credentials.
  • Once logged in, click on “Websites” in the top navigation and find your website’s “Site Tools” option.
  • Select “Site” > “File Manager” from the left navigation.
  • Locate the .htaccess File: Look in the “public_html” directory for “.htaccess.” If you don’t see it, you may need to create one.

SCREENSHOT: Note that we use WordPress in this example, so your file structure may differ depending on your website’s setup and configuration. 

Method 1, Step 2: Edit the .htaccess File

  • Open the .htaccess File: Right-click on the .htaccess file and select “Edit.” This will open the file in a text editor.
  • Backup Your File: Before making any changes, copy the existing content and save it in a separate document as a backup.

Method 1, Step 3: Write the 301 Redirects

A 301 redirect tells search engines that the location of your content has changed:

Example 301 redirect for a single URL:

Single Page Redirect: A 301 redirect is written using the following format in your SiteGround .htaccess File. To redirect an OLD URL to a NEW & IMPROVED URL, add a line like this:

# Redirect to a URL on the same domain
Redirect 301 "/blog-category/old-blog-url-url/" "/blog-category/new-fancy-url/"

Directory Redirect: If you want to redirect an entire directory or category to a new one, use this format:

# Redirect to directory on the same domain
Redirect 301 "/old-category/" "/new-category/"

Domain Redirect: To redirect all traffic from one domain to another, use:

# Redirect to a different domain
Redirect 301 "/product-a/" "https://newdomain.com/product-a/"

Method 1, Step 4: Save and Test Your Redirects

  • Save the Changes: After adding the necessary redirects, “Save” the .htaccess file.
  • Test the Redirects: Open a web browser and test the old URLs. They should redirect to the new URLs you specified.

Method 2: Using the Redirect Console

Phew! On to method two, which is admittedly more straightforward… SiteGround provides an easy-to-use Redirect console within its Site Tools, simplifying redirect setup without editing the .htaccess file directly.

Method 2, Step 1: Access the Redirect Console

  • Log into SiteGround: Go to your SiteGround account and log in.
  • Navigate to Site Tools: Select “Site Tools” for the website you want to manage.
  • Open the Redirect Tool: Find “Redirects” under the “Domain” section.

Method 2, Step 2: Set Up a 301 Redirect:

  • Fill in the Details: Choose your domain and specify the “Path,” which is the OLD URL.
  • Select Redirect Type: Ensure “Permanent (301)” is selected.
  • Define New Destination: Enter the NEW URL into the “Redirects to” section
  • Save the Redirect: Click “Create” to save your redirect.

IMPORTANT: Be careful when using “www.example.com” instead of “example.com” in the new URL path. If you are inconsistent, search engines may encounter duplicate content issues. 

Practical Tips

  • Use Relative Paths: When writing redirects within the same domain, use relative paths (e.g., /old-page.html). For cross-domain redirects, use the full URL (e.g., http://www.example.com/).
  • Check for Errors: Ensure the .htaccess file is free of syntax errors. Even a small mistake can cause the redirects to fail.
  • SEO Considerations: Use 301 redirects for permanent changes to retain SEO rankings. Avoid using 302 redirects, as these are for temporary changes.

Following these steps and examples, you can efficiently manage URL changes on your SiteGround-hosted website with 301 redirects.

Ad - Web Hosting from SiteGround - Crafted for easy site management. Click to learn more.

Now, It’s Your Turn

A basic understanding of 301 redirects and how to implement them is critical for managing your website. This helps make content accessible to search engines and users. As long as you are careful and take regular backups of your .htaccess file before making changes, you shouldn’t worry. Happy redirecting!

Related Articles

Our Commitment to Our Readers...

We are only successful if we are helping your small business succeed, and for us, that starts with high-quality content. If any of our content has not answered your initial search query, created a positive experience, or if the content has not met your expectations, please contact paul@smallbizsetup.org. We want to hear from you and are committed to improving our resources to better meet your needs. Like, actually!