.htaccess - Redirecting a web folder directory to another htaccess -


sorry has no doubt been asked multiple times before, want clarification following code redirect url on olddomain.com newdomain.com homepage not equivalent url:

rewriteengine on rewritecond %{http_host} !^www\.olddomain\.com$ rewriterule (.*) http://www.newdomain.com/$1 [r=301,l] rewritecond %{http_host} !^olddomain\.com$ rewriterule (.*) http://www.newdomain.com/$1 [r=301,l] 

also if wanted subdomain on olddomain.com eg.subdomain.olddomain.com go homepage of newdomain.com have do? can use universal selector or have write condition each subdomain so:

rewritecond %{http_host} ^subdomain.olddomain.com$  rewriterule ^(.*)$ http://subdomain.newdomain.com/$1 [r=301,l]  rewritecond %{http_host} ^www.subdomain.olddomain.com$  rewriterule ^(.*)$ http://subdomain.newdomain.com/$1 [r=301,l] 

both of attempts not correct first redirect:

http://olddomain.com/foobar http://newdomain.com/foobar 

not homepage of newdomain. same problem 2nd rule.

you can use code in document_root/.htaccess file:

rewriteengine on  rewritecond %{http_host} ^(www\.)?olddomain\.com$ [nc] rewriterule ^ http://www.newdomain.com/ [r=301,l]  rewritecond %{http_host} ^(www\.)?subdomain\.olddomain\.com$ [nc] rewriterule ^ http://subdomain.newdomain.com/ [r=301,l] 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -