I have changed the main domain to a sub-domain & would like to re-direct all external links to the new sub domain. Have read a few articles but having no luck editing the .htaccess as it might be interfering with all the rules in there.

Old: www.example.co.uk
New: https://secure.example.co.uk

The current rules are quite handy because it seems to have sorted out the structure for all internal links. It has even updated the file path for images (or this could just be wordpress as the url was updated under general settings).

This is the current .htaccess

<files wp-config.php>
order allow,deny
deny from all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

1 Answer 1


To just check if the url contains the secure. subdomain, just use a HTTP_HOST condition where you redirect if it does not start with secure. like so:

RewriteCond %{HTTP_HOST} !^secure\.
RewriteRule ^(.*)$ https://secure.example.co.uk/$1 [R=301,NC]

Now as far as external links vs internal links, I would have to see examples of each to write another condition to only affect "external" links if redirecting "internal" links is problem for some reason put this as the first rule after RewriteBase / and you should be ok.

  • That change didn't work unfortunately. I think setting up individual re-directs in cpanel will work but be long winded. For example example.co.uk/joebloggs re-direct to secure.example.co.uk/joebloggs example.co.uk/joebloggs/who-is-he re-direct to secure.example.co.uk/joebloggs/who-is-he etc etc.
    – user20390
    Dec 4, 2012 at 9:53
  • Google won't let you have a sub domain as the main domain. Thanks for the answers need to sort out with my host. The problem all started with our shopping cart system only allowing https:// for secure checkout, it doesn't let you easily use of a sub domain like secure.example.co.uk without messing around with all the code. Thanks
    – user20390
    Dec 4, 2012 at 10:20
  • ssl certificates are usually subdomain specific so your cert for www. wouldnt be valid for secure. (you can get multi subdomain certs but they cost more and arent standard issue). Try it without the https:// (just http://) and see if its still redirecting correctly otherwise.
    – WebChemist
    Dec 4, 2012 at 10:34
  • @Dean: Google won't let you have a sub domain as the main domain. -where did you hear that? Jan 3, 2013 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.