
: 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
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/
More posts by @Murray155
1 Comments
Sorted by latest first Latest Oldest Best
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].
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.