Jump to content

Recommended Posts

Hello

 

Would anyone be able to help with this small problem...

 

I have 2 domains, www.example.co.uk and www.example.com

 

They are configured by my host to share the same webspace

 

What I would like however, is to use .htaccess to redirect a visitor who accesses the site via www.example.com to be redirected to www.example.co.uk

 

I somehow need to add this into my existing .htaccess code which redirects a non-www domain to a www domain for SEO purposes

 

Does anyone know how this may work?

 

In summary -

2 domains pointing to the same shared directory.

The .com domain (both http://www.example.com and http://example.com) need to redirect to www.example.co.uk

The .co.uk (http://example.co.uk) must also redirect to the www version (http://www.example.co.uk)

 

The code I currently have is below (this redirects non-www to www):

 

RewriteEngine On

RewriteBase /

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

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

 

Any suggestions welcome  :D

 

Link to comment
https://forums.phpfreaks.com/topic/236898-simple-htaccess-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.