• Hi All

    First post here so not sure if I am at the right place or even the right forum. I have been asked to set up a WordPress blog which I have done using Apache and PHP

    I am trying to redirect the website so that when someone types in websitename.co.uk it is directed to https://www.websitename.co.uk

    However the htaccess file that has been generated does not seem to allow this.

    The code is

    # BEGIN WordPress
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^websitename.co.uk$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.websitename.co.uk$ [NC]
    RewriteCond %{REQUEST_URI} !^/blog/
    RewriteRule ^(.*)$ /blog/ [L]

    # END WordPress

    I really am not that good at php so where am I going wrong?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The url is controlled via the admin under Settings > General > WordPress Address (URL) > https://www.example.com

    A manual 301 redirect would look like this:

    RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example\.com
          RewriteRule (.*) https://www.example.com/$1 [R=301,L]

    However if it is set differently in your admin this will break the site as WordPress will be redirecting to non www. whilst the .htaccess tries to force www.

    If I may, you could also try this:

    # Require “www”
    RewriteCond %{HTTP_HOST} !^www\.websitename\.co\.uk [NC]
    RewriteRule .* https://www.websitename.co.uk/$1 [R=301,L]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to amend a .htaccess file’ is closed to new replies.