PHP Redirect – 2 domains pointing to one website

Share on facebook
Facebook
Share on twitter
Twitter

My company was recently hired to take over the management of the Fort Myers Beach Chamber of Commerce website, and as we dugg thru the site, the databases and the emails, I realized that the Chamber had two domain names, and 2 identical websites. FortMyersBeach.org, and Fmbchamber.com. Not good! Not good because the all of the backlinks, page rank and content was being shared over two websites, hindering the website’s search engine performance.

So, we had to figure out a way for both domains to still show the Chamber website, but to not lose the rankings and link juice for either website. As the websites are in PHP, we decided that the best way to go about this process was with .htaccess file re-directs. Pretty simple implementation involved as you can see from the small snippet of code below. All you have to do is add this code to your .htaccess file (create one if you do not have one already) , and yes, that is a period before the “h”.

.htaccess files only work on Apache servers so before you use them make sure your server allows this file.

Code:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.fmbchamber.com [nc] rewriterule ^(.*)$
http://www.fortmyersbeach.org$1 [r=301,nc]

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^fmbchamber.com [nc] rewriterule ^(.*)$
http://www.fortmyersbeach.org$1 [r=301,nc]

It is pretty obvious what is going on in this code. I am telling the server to permanently redirect any fmbchamber.com and www.fmbchamber.com url’s to www.fortmyersbeach.org. I threw this together real quick and I’m sure hardcore php developers have a much cleaner way of coding this, but this snippet works perfectly for its purpose.

Let's Talk
We can't wait to hear about your project.
  • required
  • required
  • required
  • required
    *Sorry, "Johnny Flyaway" recently retired. We hope an email response or phone call will suffice.
    Spam isn't fun. We promise to only send you emails with helpful marketing & design tips, and life changing information. Ok, maybe the latter is a bit of an exaggeration, but it's possible!
  • This field is for validation purposes and should be left unchanged.
Web & Logo Design Blog

© 2021 Brian Joseph Studios LLC. All rights reserved

Facebook | Twitter | Instagram | Web Design Naples | Web Design Fort Myers | Logo Design Fort Myers | Logo Design Naples | LinkedIn

Fort Myers - (239) 989 3306 | Naples - (239) 280-1294

Google Business Listing - Brian Joseph Studios - Naples Web Design Company