Edit
Contact us
Salocin Group Leaders in data and AI-enabled connected customer experiences
Edit Engineers of connected customer experiences
Join the Dots Independent, data-led media thinking for sustainable growth
Wood for Trees Optimisers of future fundraising performance
  • Home
  • Our services
    • Cloud solutions
    • Data science
    • Modern Data Platform
    • Privacy and AI compliance
  • Our partners
    • Microsoft
    • Apteco
    • Salesforce
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Salocin Group
    • Careers
  • Contact Salocin Group
  • Home
  • Who we are
    • B Corp
    • Careers
  • Our work
  • What we do
    • Intelligent data
    • Marketing technology
    • Transformational CRM
    • Our technology partners
    • Privacy review
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • Contact Edit
  • Home
  • Broadcast media
  • Digital media
  • Print
    • Direct mail
  • Data
    • Our work with Herdify
    • EPiC
  • Media agency
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Join the Dots
    • Careers
  • Contact Join the Dots
  • Home
  • Services
    • Actionable insight
    • Data discovery
    • Data engineering
    • Data hygiene
    • Privacy review
  • Products
    • InsightHub
    • Apteco
    • Microsoft
    • Data management
    • Consent and preference management
  • Our insights
    • Blog
    • Case studies
    • Reports
    • Webinars
    • Whitepapers
  • About Wood for Trees
    • Operating principles
    • Careers
  • Contact Wood for Trees
Blog

Setting up permanent 301 Redirects in htaccess

By Edit | 9 Dec 2015

We published this a long time ago…

Some of the content in this post might be out of date, and some images and links may no longer work.

Discover who we are and how we may be able to help you today:

Learn more

A 301 redirect is the Google recommended way to change the URL of a page showing in organic search results. If implemented correctly this can prevent your site from losing traffic from any broken links displayed in your Search Console.

One of the ways in which you can implement 301 status codes is through the use of your .htaccess file, but several Content Management Systems (CMS) that have their own built in functions or extensions, plugins or modules to take care of this for you.

These functions write commands in the .htaccess file but do so by offer you a far more user friendly interface to work with as opposed to having to access the raw file via the File Transfer Protocol (FTP).

What is an .htaccess file and what can I do with it? Supported by most web servers, your .htaccess or hypertext access file is exactly as the name suggests – it allows you to control which users can access your site allowing you to enter password restrictions and more. However, it can also be used to override and configure your site settings much like we will be doing with the 301 redirect.

Please be very careful when editing this file, ensuring you save a backup to your PC before making any changes as even a minor misplaced character can cause your site to crash, so make sure everything you do is reversible.

If your website doesn’t have a CMS or has one that doesn’t offer any 301 redirect functions then unfortunately you’re going to have to write them in your .htaccess file manually. The easiest way in which to access this is through a FTP program – I personally suggest FileZilla a free and easy to use client.

Once you have that downloaded you will need to get your sites address which will be in the form of an Internet Protocol (IP), and a username and password which can all be set up through your website’s cPanel. If you’re struggling to find your website IP you can do so by using free internet tools like Site24x7, you can also use this step by step guide on how to access your site FTP through Filezilla.

Once you have successfully accessed your site you will need to locate the file. Typically, this is located under the “/” folder – on the left hand side you will see your computer documents and on the right your raw website files. Once you have found the file you are looking for, right click and select “View/Edit” in Notepad/Wordpad and follow the steps below.

Individual 301 redirects

Implementing individual URLs is fairly simple.  Take for example if I wanted to redirect this page to edit.co.uk/blog/ I would write this on a new line:

Redirect 301 /setting-up-permanent-301-redirects-in-htacces/ /blog/
 
 

Redirecting an entire domain

Let’s say I have purchased both the .com and .co.uk domains, and wanted to redirect the .com site to my .co.uk site. I would do this by accessing the FTP for my .com domain and input this through writing a rewrite condition. Here is an example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^edit.co.uk [NC,OR]

RewriteCond %{HTTP_HOST} ^www.edit.co.uk [NC]

RewriteRule ^(.*)$ http://branded3.co.uk/$1 [L,R=301,NC]
 
 

This rule would mean that the Edit.com URL would redirect to Edit.co.uk.

Forcing certain protocols

You may find that your site has duplicate pages when you’re running crawls which can be due to two versions of pages being indexed  for example www.edit.co.uk and edit.co.uk or potentially due to a trailing “/” at the end of the URL.

You can avoid this issue completely by forcing your website to use a certain version of the domain, you do this by adding a rewrite rule in the .htaccess, and here is an example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.edit.co.uk [NC]

RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
 
 

This would stop Google indexing any www. and apply a trailing slash to all URLs, preventing any potential duplicate pages.

Using your .htaccess file to make changes directly has both its advantages and disadvantages just like anything else. Some of the advantages of redirecting this way is that changes are immediate and the .htaccess is read on every server request, so there is no chance of Google indexing URLs you don’t want to be indexed.

The disadvantage of using this method to redirect your site is that it can cause a slight performance loss, as every {HTTP} request you make inside of the document is an additional file that needs to be accessed, but there are methods of avoiding this.

HTAccess is a powerful file where you can control a lot of how your website acts and performs due to it being a directory level document.

There are several things you can look to change in your HTAccess file in order to benefit your site’s SEO, including converting dynamic link URLs into a better looking and ranking structure.

You can also redirect index.php to the root or any .php based links for that matter, and also redirect www. to non www. There are also several more nice little tips and tricks, in which I will touch upon in follow up posts.

We published this a long time ago…

Some of the content in this post might be out of date, and some images and links may no longer work.

Discover who we are and how we may be able to help you today:

Learn more

Share this

  • Email
  • WhatsApp
  • LinkedIn
  • Facebook
  • X (Twitter)

More insights

AI isn’t going to take your job (unless you really want it to) 
Blog

AI isn’t going to take your job (unless you really want it to) 

By Edit | 18 Jun 2024
Customer relationship marketing: How generative AI is revolutionising engagement  
Blog

Customer relationship marketing: How generative AI is revolutionising engagement  

By Edit | 4 Apr 2024
Personalisation as a process
Blog

Personalisation as a process

By Edit | 8 Mar 2024
  • Privacy policy
  • Cookie policy
  • Ts&Cs
  • Report a concern

© 2025 Edit, part of Salocin Group Ltd. All rights reserved. Company no.: 0362​4881. VAT no.: 4208​34911.

Salocin Group Certified B Corporation | Cyber Essentials Certified | British Assessment Bureau, ISO 27001 Information Security Management
Salocin Group
Your cookie preferences

We use cookies to ensure this website functions properly, to analyse website traffic and for marketing purposes.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}