문제

Am trying to do the following. My website is hosted on

www.sitehost.com/uk

But I own this domain.

www.mainsite.co.uk

Is it possible to redirect the user hitting www.mainsite.co.uk to www.sitehost.com/uk but retain the www.mainsite.co.uk?

I tried doing .htaccess redirect and it worked but it changed the URLs from www.mainsite.co.uk to www.sitehost.com/uk

Ideally it would work like so...

www.sitehost.com/uk/post/20

can be accessed via

www.mainsite.co.uk/post/20

I tried mod_proxy but it didn't seem to work all the way. Anyone know how to do this? Is this even possible with Apache?

도움이 되었습니까?

해결책

This is possible if mod_proxy is enabled in your Apache config.

Once mod_proxy and mod_rewrite are enabled place this rule in your DocumentRoot/.htaccess file of sitehost host:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?sitehost\.com$ [NC]
RewriteRule ^ http://www.mainsite.co.uk%{REQUEST_URI} [L,P]

P flag is used for proxying the request to external URL.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top