Mobile app version of vmapp.org
Login or Join
Miguel251

: 301 re-direct all external links to new domain 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

@Miguel251

Posted in: #301Redirect #Domains #Htaccess #Redirects #Seo

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: example.co.uk New: 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
</files>
# 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]
</IfModule>

# END WordPress

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Miguel251

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rivera981

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 ^(.*)$ secure.example.co.uk/ [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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme