0

So I'd like to use a htaccess file to forward a domain:port onto another domain:port

In this case I'll use this example of what I want to achieve

DomainA.co.uk --> DomainB.co.uk
DomainA.co.uk/* --> DomainB/*
DomainA.co.uk:8000/* --> DomainB:8000/*

even better would be able to forward any and all ports on like so

DomainA.co.uk:*/* --> DomainB:*/*

Thoughts would be greatly appreciated,

Thanks

Henry

Addition : The OS i am running is cPannel/WHM 60.8 on CentOS

Henry Aspden
  • 1,863
  • 3
  • 23
  • 45
  • Possible duplicate of [.htaccess URL redirect](http://stackoverflow.com/questions/3374696/htaccess-url-redirect) – jas_raj Feb 07 '17 at 16:19
  • @jas_raj slightly different I believe due to the ports. I could do a standard redirect on the domain with wildcards, but the ports issue throws a spanner in the works... – Henry Aspden Feb 07 '17 at 17:49

2 Answers2

0

Redirecting a domain wholesale can be achieved with directive Redirect

Redirect / http://DomainB.co.uk

or to domain B with port 8000

Redirect / http://DomainB.co.uk:8000
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
0

You can use the following RewriteRule :

RewriteEngine on
RewriteRule ^ http://domainB.com:%{SERVER_PORT}%{REQUEST_URI} [NE,L,R]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115