FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Google Indexing .Com and .Com/index.php --> Redirect





GoldenEagle
Google is indexing both domain.com and domain.com/index.php, which is not good for SEO and putting all of my eggs in one basket. I've looked around on the internet to no avail.

Many people have been mentioning this Apache mod_rewrite thing, but I really can't make sense of it.

Can someone help me out with this? Thanks!
Bondings
Create a .htaccess file in your public_html directory with something similar (replace frihost.com with your domain):

Code:
RewriteEngine On

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

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.frihost.com/ [R=301,L]

The first line enables url rewriting.

The next 2 lines make sure that there is a redirect from the non-www version to the www version.

The last 2 lines redirect the index.php file to the domain.

In both cases, the redirecting is done with a 301, which is a permanent redirect.
nepalstar
If google is indexing both domain.com and domain.com/index.php then what will be the effect of this change...? plz inform me I'm new to this...!
Bondings
You can redirect the index.php page to the domain. Otherwise Google might see it as 2 separate, but duplicate pages.
GoldenEagle
Thanks, Bondings. What if I wanted to go the other way, like www. --> non-www ?

I have the redirect eliminating the /index.php part of it all squared away.
Bondings
GoldenEagle wrote:
Thanks, Bondings. What if I wanted to go the other way, like www. --> non-www ?

I have the redirect eliminating the /index.php part of it all squared away.

I would assume something like this (not tested):

Code:

RewriteCond %{HTTP_HOST} ^www\.frihost\.com$ [NC]
RewriteRule ^(.*)$ http://frihost.com/$1 [R=301,L]
bruks
Or robots.txt
Disallow: /index.php
Related topics
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Web Hosting Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.