apache - Using .htaccess to serve root domain content from subdomain -
i have php app requires domain's document root set /(wherever)/app_dir/www
run (which can't changed, sadly). unfortunately, on host can't change document root main mydomain.com
(from /public_html
/public_html/app_dir/www
can edit document root subdomains.
subdomains stored in /public_html/subdomain.domain.com
, , setting root subdomain /public_html/subdomain.domain.com/app_dir/www
allows app display content fine @ http://subdomain.domain.com/
.
in order have content appear @ root domain (where can't install since document root uneditable), i'm trying use .htaccess serve content subdomain without redirecting browser, going www.domain.com
show www.domain.com
in location bar, serving contents of subdomain.domain.com
(and likewise www.domain.com/something
pulling instead subdomain.domain.com/something
).
as understand it, mod_proxy should able (and installed). based on other answers similar queries, looks should solution:
rewriteengine on rewriterule ^(www.)?domain\.com$ http://subdomain.domain.com/$1 [l,p]
i've been trying simple index.html dummy in place of more complex, either syntax off (i've tried several variations, without joy, including without p option; i'm no expert , previous .htaccess experience limited simple rewrites , 301 redirects), i've missed blindingly obvious, or i'm barking wrong tree entirely, because dummy index file i've got @ root domain instead of equally dummy index file sitting in subdomain's root (which displays fine if go subdomain.domain.com
, that's not aim).
any appreciated!
this rule wrong , faulty, doesn't believe should doing:
rewriterule ^(www.)?domain\.com$ http://subdomain.domain.com/$1 [l,p]
remember rewriterule
matches request_uri
without domain , query string parts.
if mod_proxy enabled can have rule instead:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^www\.domain\.com$ [nc] rewriterule ^ http://subdomain.domain.com%{request_uri} [p,l]
if reason mod_proxy not enabled them please let me know, suggest alternative solution.
Comments
Post a Comment