Link to home
Start Free TrialLog in
Avatar of Neil Thompson
Neil ThompsonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

rewrite a subdomain to a path using Apache?

Hi

I've been asked if I can rewrite an address using Apache 2.2

I'm trying to get and of these
members|intranet|email to become the path after a preset domain, whatever http or https method used initially should also follow through

eg.

http://members.bbb.co.uk should re-write to http://www.bbb.co.uk/members
https://members.bbb.co.uk should re-write to https://www.bbb.co.uk/members

and so on

I think I need something like this but not really sure what I am doing here:
#RewriteRule ^(members|intranet|email)(?:/(.*))?$ https://aa.bbbbbbb.co.uk/$1 [P]

Thanks in advance
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Don't you have that backwards?  The first item is what is seen in the browser and the second item is where it goes on the server.

http://www.bbb.co.uk/members should re-write to http://members.bbb.co.uk
https://www.bbb.co.uk/members should re-write to https://members.bbb.co.uk
On my site it looks like this.
RewriteEngine on  

RewriteCond %{HTTPS} !=on
RewriteRule ^members  http://members.bbb.co.uk/

RewriteCond %{HTTPS} =on
RewriteRule ^members  https://members.bbb.co.uk/

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Neil Thompson

ASKER

Many thanks , spot on