Help with 301 redirect

by doggax
6 replies
  • SEO
  • |
Hello,

I have changed the URL slightly on 3 pages and need to 301 redirect them but I'm unsure how to add the redirects in the .htaccess file?

Can anyone help please?

https://www.mywebsite.co.uk/areas/we...ands/stafford/ to https://www.mywebsite.co.uk/areas/we...staffordshire/
https://www.mywebsite.co.uk/areas/we...ands/hereford/ to https://www.mywebsite.co.uk/areas/we...herefordshire/
https://www.mywebsite.co.uk/areas/we...lands/warwick/ to https://www.mywebsite.co.uk/areas/we.../warwickshire/

# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /tgf/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /tgf/index.php [L]
</IfModule>

# END WordPress
#301 #redirect
Avatar of Unregistered
  • Profile picture of the author ThereseWright
    Add this code before the "# END WordPress" line:

    Redirect 301 /old-url https://yourdomain.com/new-url

    Example:
    Redirect 301 /areas/west-midlands/stafford/ https://www.mywebsite.co.uk/areas/we...staffordshire/

    Make sure you make a backup of your .htacess file before you make any changes. Although I should ask: Why not just use a plugin?
    {{ DiscussionBoard.errors[11572575].message }}
    • Profile picture of the author MikeFriedman
      Originally Posted by ThereseWright View Post

      Although I should ask: Why not just use a plugin?
      Using plugins for simple redirects is a terrible idea. Adding plugins slows down sites. It also adds potential security vulnerabilities. You should only add plugins that you need.
      {{ DiscussionBoard.errors[11572738].message }}
      • Profile picture of the author Jeffery
        Originally Posted by MikeFriedman View Post

        Using plugins for simple redirects is a terrible idea. Adding plugins slows down sites. It also adds potential security vulnerabilities. You should only add plugins that you need.

        Agreed.


        Also, some of those plugins will revert back to the original .htaccess when deactivated unless the user purchases the paid version.
        Signature
        In the minute it took me to write this post.. someone died of Covid 19. RIP.
        {{ DiscussionBoard.errors[11573066].message }}
  • Profile picture of the author TechMate001
    Dont fight with this then it will be a hectic thing for you....Simply you can reach out hosting providers and ask them to fix in htacess simple...
    {{ DiscussionBoard.errors[11596848].message }}
  • Profile picture of the author Forseti
    As I understand it, you are using WordPress. It has special plugins for redirecting and removing duplicate pages. It would be easier for you to use them if you do not understand the technical part
    {{ DiscussionBoard.errors[11599378].message }}
  • Profile picture of the author cmsminds
    If you have a small number of URLs that need to redirect then you can use the below code.

    Redirect 301 OLD URL NEW URL

    If you have huge number of URLs that need to redirect, then use any Wordpress plugin or ask your website hosting provider for the best solution which does not affect our website loading speed.
    {{ DiscussionBoard.errors[11599675].message }}
Avatar of Unregistered

Trending Topics