apache - How could htaccess redirect two hosts to subdirectory -
how both localhost , remote hosts redirect root sub-directory?
local host: domain.localhost
remote host: domain.com
sub directory: subdir
domain.localhost -> domain.localhost/subdir/<br> domain.localhost/ -> domain.localhost/subdir/<br> domain.com-> domain.com/subdir/<br> www.domain.com -> www.domain.com/subdir/<br>
options +followsymlinks directoryindex questions.php rewriteengine on rewritecond %{http_host} ^domain\.localhost$ rewriterule ^(.*)$ http://domain\.localhost/subdir/$1 [r=301,l] rewritecond %{request_uri} ^/$ rewriterule (.*) http://www.domain.com/subdir/ [r=301,l]
for principles:
domain.localhost -> domain.localhost/subdir/ domain.localhost/ -> domain.localhost/subdir/ domain.com-> domain.com/subdir/ www.domain.com -> www.domain.com/subdir/
here precise rewriterules:
options +followsymlinks directoryindex questions.php rewriteengine on # domain.localhost -> domain.localhost/subdir/ rewritecond %{http_host} ^domain\.localhost$ rewriterule (.*) /subdir/$1 [qsa,l] # domain.com -> domain.com/subdir/ rewritecond %{http_host} ^(www\.)?domain\.com$ rewriterule (.*) /subdir/$1 [qsa,l]
if doesn't work try without "/
":
options +followsymlinks directoryindex questions.php rewriteengine on # domain.localhost -> domain.localhost/subdir/ rewritecond %{http_host} ^domain\.localhost$ rewriterule (.*) /subdir$1 [qsa,l] # domain.com -> domain.com/subdir/ rewritecond %{http_host} ^(www\.)?domain\.com$ rewriterule (.*) /subdir$1 [qsa,l]
nb: there's no need make redirect [r]
directive. there's no need precise whole domain.
Comments
Post a Comment