user3205692
user3205692

Reputation: 21

Rewrite from sub domain without change url

Structure
 public_html
  -.htaccess
  -subdomain
  -codefolder

The task that the subdomain should look in codefolder but did not change URL. Is it possible?

I try


    RewriteEngine on

    RewriteCond %{HTTP_HOST} subdomain.example.com
    RewriteCond %{REQUEST_URI} !^subdomain.example.com
    RewriteRule ^(.*)$ http://example.com/ [L]

But it certainly leads to a change in the URL, but I do not need it.

Upvotes: 2

Views: 262

Answers (1)

user3205692
user3205692

Reputation: 21

I solved the question through a symlink.

ln -s  /path-to/subdomain codefolder

and in htaccess

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com
RewriteRule ^(.*) /example/public/%1 [L]

This is not the best option, but my hosting does not have access to the Apache configuration.

Upvotes: 0

Related Questions