Forum Moderators: Robert Charlton & goodroi
When I installed my forum, I deleted the index.html page. The main page is now index.php.
However, google still has the old index.html page indexed, and is indexing the index.php page as a separate page. This is affecting my ranking because google is not indexing the main page of my new site.
Any suggestions?
[edited by: MWpro at 2:47 am (utc) on Jan. 27, 2008]
Additionally, any access to a named index page URL should issue a 301 redirect back to the root URL ending with the / at the end.
This avoids that problem, as well as any potential Duplicate Content issues that could arise.
Merging www.example.com/ and www.example.com/index.htm
Itwould be helpfull to a few of us if this where added to sitemaps too
[webmasterworld.com...]
Split pagerank on index.htm
Split pagerank on index.htm
[webmasterworld.com...]
Both of the above cover index.php as well.
You might also want to read the threads on Duplicate Content in Google Hot Topics [webmasterworld.com], pinned to the top of the home page of this forum.
Right now this is what my .htaccess looks like. Will this solve my problem? Thanks!
DirectoryIndex index.phpRewriteEngine On
rewritecond %{http_host} ^mysite.com
rewriteRule ^(.*) [mysite.com...] [R=301,L]Redirect 301 /index.html [mysite.com...]
Additionally, you should not mix up directives from different modules. Don't use Redirect for one part and RewriteRule for the other part.
You will not be able to control the order the directives are processed.
Use RewriteCond for both parts, and do the more specific redirects first. Make sure that the redirect goes direct to the target URL in ONE step, not in multiple steps.
Finally, your index redirect only works for index files in the root. You should set it up so that it works for all index files in any depth of folder too; and preserves the folder path in the redirect.
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*\/index\.php
RewriteRule ^(.*)index\.php$ http://www.example.com/$1 [R=301,L]
Will this fix it?
I also had the other code to direct mysite.com to www.mysite.com
How can I do this both?
.htaccess is not my strong suit so as much help as you can give me would be appreciated.
[edited by: tedster at 7:24 am (utc) on Jan. 30, 2008]
[edit reason] switch code to example.com - it can never be owned [/edit]
2. Redirect all non-www to www, preserving any folder path. This rule runs for non-www URLs, but does not run for index files at non-www because rule 1 has already fixed them up to be completely correct, in one step.
If you reversed rule 2 and rule 1 you would have a redirection chain for non-www index files. You must avoid that happening. The order, above, is the correct one to use. Example code has been posted in the apache forum hundreds of times, and is linked from the sticky thread at the top of that forum.
How is this looking:
DirectoryIndex index.phpRewriteEngine on
RewriteCond %{THE_REQUEST} ^.*\/index\.html
RewriteRule ^(.*)index\.html$ http://www.example.com/$1 [R=301,L]RewriteEngine On
rewritecond %{http_host} ^example.com
rewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
[edited by: MWpro at 9:25 pm (utc) on Jan. 30, 2008]