Jump to content

Simple .htaccess question


lbh2011

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.