Mobile app version of vmapp.org
Login or Join
Murray155

: Subdomain Masking, redirection already provided I'm using a server which allows me to create and redirect subdomains. However, it is reflected on the address URL bar. What I want is to keep

@Murray155

Posted in: #Masking #Subdomain

I'm using a server which allows me to create and redirect subdomains. However, it is reflected on the address URL bar.

What I want is to keep subdomain.domain.com as base URL for the subdirectories inside domain.com/subdirectory/

Searching on the internet I always come up with these lines for .htaccess, which I think it does the redirection, but not the masking.

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/sub
RewriteRule ^(.*)$ sub/ [L]


edit

Tried this, but didn't work

RewriteEngine on
RewriteBase /subdirectory/
RewriteRule ^(.*)$ subdomain.domain.com/ [P]
ProxyPassReverse /subdirectory/ subdomain.domain.com/

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray155

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

What you are asking for is solved using mod_proxy with mod_redirect. Research this Apache documentation page: httpd.apache.org/docs/current/rewrite/proxy.html
I do warn you that you have to be careful when configuring your Apache to mod_proxy. Here is the Apache documentation on that. There is a strong warning on the top of the page. But do not let that scare you. Just be careful and thorough.

Having said that, I used to use this feature A LOT! If configured safely, it works extremely well, is seamless, and highly reliable.

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/sub [NC]
RewriteRule .* sub.domain.com [P,L]


You do not need RewriteBase unless it is something other than the default.

I think this example will work for you. If not, I will change the example and we will try again. To test, use [R,L] instead of [P,L].

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme