0

I need to point (not redirect) a sub domain to a directory in the root domain. For example I have the following domain:

https://test.example.com

I would like that to point to the directory:

https://example.com/apple

This needs to happen without changing the URL from the subdomain. It also needs to include any URL parameters, example:

https://test.example.com/hello-world

Should point to (not redirect) to:

https://example.com/apple/hello-world

In my .htaccess file (in the root directory of the subdomain) I have:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^test\.example\.com$
RewriteCond %{REQUEST_URI} !^/apple$
RewriteRule ^(.*)$ https://example.com/apple/$1

This works but it redirects. Any suggestions on how to point the sub domain to that directory without redirecting without using mod_proxy?

Brett Gregson
  • 5,867
  • 3
  • 42
  • 60

1 Answers1

0

Try below rule I am assuming both domains are pointing at same location.

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^test\.example\.com$
RewriteRule ^(.*)$ apple/$1 [L]
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45