Make search engines love PHPmotion (part 2)

Part 2 of the PHPmotion seo series is now done (part 1 here)! In this article I will be concentrating on improving the .htaccess file to remove duplicate content & set up correct redirect headers for links.

Having 2 addresses to display the same content is bad (search engines may think you’re trying to trick them) and un-necessary. By having only one link for each page also means that there is no chance of visitors linking to different urls for the same content. A few changes in the .htaccess and all will be well!

To www or not to www

Choose which ever you prefer and redirect all the others over to it.

To redirect from non www to www

RewriteCond %{HTTP_HOST} ^yourdomainname.com [NC]
RewriteRule (.*) http://www.yourdomainname.com/$1 [R=301,L]

To redirect from www to non www

RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

Adjust the audio/video/image/blog listing pages

If you use a duplicate content checker to check the following urls:

  • http://v3.phpmotion.com/videos
  • http://v3.phpmotion.com/videos/load/recent

You will see they are both identical. To correct this you could (should) change the links in the template files (themes/yourtheme/templates/main_1.htm) to point to videos/load/recent or vice-versa.

But we don’t want to lose any existing value on the old links do we? So we’ll just add a 301 redirect so everyone knows to use the other link from now on. Add the following line after RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^videos(/?)$ videos/load/recent [R=301,L]

If you chose to replace all videos/load/recent links with just videos you should use this code:

RewriteRule ^videos/load/recent(/?)$  videos [R=301,L]

Now you just need to do similar for each of the media links in the main menu (audios, blogs & images). You only need to do this for the load/recent links the other load/featured, etc… should be fine.

If done correctly (once you make the changes make sure that they work!) then you’ll have just done yourself a favor. Also if you don’t already use Google Webmaster tools then make sure you check it out! It will help show issues with your website and also give you some info like the top search queries, etc..

, ,

9 Responses to “Make search engines love PHPmotion (part 2)”

  1. This is great stuff. I just made the changes on my V3 site, and love the results. Thanks for the excellent info, Ben.

  2. Ben says:

    Glad it helps, I’d like to do more posts like this but I’m a bit busy at the moment. Hopefully things will calm down soon and I’ll be able to write some more.

  3. What code is required for aaplying an seo url to the pages eg, contact us page, terms etc?

    I added this to .htaccess:
    RewriteRule ^page/([^/]*)$ page.php?page=$1 [L]

    and this to directory browsing list:
    RewriteRule ^page(.?)$ page.php [L]

    All i get is ‘domain.com/page.php?page=3′ for these pages.

  4. Ben says:

    Something like RewriteRule ^page/([^/]*)$ page.php?page=$1 [L] should work with links .com/page/1 if you wanted to use .com/page/about you’d be best to write individual rules for each page.

    RewriteRule ^about/?$ page.php?page=X [L]
    Where X is the page id for the about page (1)

  5. RevJeff says:

    OMG dude! This is so awesome! I have been designing and hosting sites for years and never ever thought about what people do when they go to a site without the www.

    So flipping cool. Made me think and act. :)

  6. cybernoypi says:

    awesome! how about with sub-folder redirects with non-www or www redirects

  7. Ben says:

    There shouldn’t be anything extra to do for sub folders the above should work ok.

  8. diakbar says:

    bro, I have a site with phpmotion installed, and i wonder why my site is redirect from www to non-www, my site http://www.ee.ui.ac.id/netlabs/phpmotion, as you will see that the phpmotion will redirect from www to non-www, help please,. thanks

  9. Ben says:

    Check in classes/settings.php if you have the domain name set with www or not. That’s probably the issue.

Leave a Reply

RSS feed