Arthur Flower
Arthur Flower

Reputation: 335

apache .htaccess: hiding subdomain redirect

I have this problem: I want for example that http://www.mydomain.com/experiential/mypage will be redirected to http://subdomain.mydomain.com/mypage without showing the change in the address bar. Physically, the domain and subdomain will be hosted on different servers.

Is there any way to achieve this?

I have tried with

RewriteRule ^experiential/(.*)$ http://subdomain.mydomain.com/$1 [L,QSA]

But the redirect shows in the acdress bar

Thanks for your help

Upvotes: 1

Views: 1434

Answers (1)

anubhava
anubhava

Reputation: 784878

This is only possible if you enable mod_proxy on the Apache that is hosting www.mydomain.com. Once that is enabled have rules like this in your .htaccess:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^experiential/(.+?)/?$ http://subdomain.mydomain.com/$1 [P,L,NC]

Upvotes: 1

Related Questions