php - .htaccess Rewrite Domain & Preserve Path -


Can someone help me rewrite a domain name but preserve the path? I do not think what I'm looking for can not seem to find, a lot of articles have been found about redirection, but not to re-write.

  www.domain2.com/path1/page.html as www.domain1.com /path1/page.html www.domain2.com/path1/page.html as www.domain1 .com / path1 / page.html  

I have enough domain names.

Thank you very much for your advice or link to an article with the answer.

Stu

The following .htaccess code will do this

  RewriteBase / RewriteCond% {HTTP_HOST} at RewriteEngine! Domain1.com $ [NC] RewriteRule ^ (. *) $ Http://www.domain2.com/$1 [L, R = 301]  

For the difference in rewriting and redirection The first place is a location redirection which is not clear (the user will not see it in their browser address bar) Second is full redirection.

Re-writing non SSL, as is the need to change the URL prefix to http to https and make sure you have a valid SSL certificate .


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -