php - issue in redirecting 2 domains in one server -


i have 2 domains , both set on 1 server , when open each of them , same website same server opens . want redirect 1 of them . example have www.first.com , www.second.com both on 1 server , , want www.first.com redirected www.second.com . cannot make index redirect because both on 1 server need way creating htaccess file or . ( have tried redirect 301 , redirect 302 in htaccess didn't work )

you can use code in document_root/.htaccess file:

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

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -