Page 1 of 2

Redirect /index.php permanently?

Posted: Mon Aug 24, 2009 2:05 pm
by Knalltrauma
Hello everyone

I'd like to redirect the regular www.mysite.com/index.php permanently to www.mysite.com. The reason why to do this is, that e.g. the GoogleBot doesn't index both pages.

Does anybody knows, how to redirect it with a permanent 301?

Kind regards
:D

Re: Redirect /index.php permanently?

Posted: Sat Aug 29, 2009 12:14 am
by kavaXtreme
I'm looking for an elegant solution for this too (and /home and /home.html too). Anyone?

Re: Redirect /index.php permanently?

Posted: Tue Sep 01, 2009 3:49 pm
by djohnson1215
Hello Knalltrauma,

First, Google knows about both http://www.mysite.com/index.php and http://www.mysite.com. It is likely that Google has already canonicalized these URLs. In other words, Google has found that these two URLs are identical. They know this because either the hash values for each page are the same or Google's "near dup conotent" check has determined that these pages are the same. From Google's point of view, these two URLs are aliases of one another.

Here is how you can test. Put one URL into Google search query and see the results. Now put the other URL into Google search query and see the results. If Google has canonicalized these URLs, you will see only one URL reported by Google. Google usually picks the URL that has the highest PR value.

The 301 permanent redirect helps the search engines figure this out. 301 redirects are applied at the host server level, not at the Joomla level. Therefore, you must log into your hosting control panel and look around for the redirect options. Be sure to use a 301 redirect and not a 302 redirect. Some control panels do not make this clear. So be careful. If you have questions, contact your hosting company for directions.

Once the redirect is in place, check your redirect through an HTTP header check tool: try http://www.rexswain.com/httpview.html. The report will show you whether a redirect is in place and what it is (301 or 302, etc.).

Hope this helps,
dgj

Re: Redirect /index.php permanently?

Posted: Tue Sep 01, 2009 7:10 pm
by gobeyond
This can be done rather easily. If you do a google search, there are several sites that provide instruction on this. You need to add some rewrite codes in the .htaccess file and that is all you need.

Search engines consider index.php, index.html, or index.htm as home page. They won't consider your domain name and domain name/index.xxx two separate pages.

Re: Redirect /index.php permanently?

Posted: Tue Sep 01, 2009 8:23 pm
by djohnson1215
I stand (or rather sit) corrected. gobeyond is right. An .htaccess file is an extension of the server settings.

Learned something new today.
:-)
dgj

Re: Redirect /index.php permanently?

Posted: Wed Sep 02, 2009 12:02 am
by kavaXtreme
Actually, I have to disagree with gobeyond on this one. For one of my sites, Google Webmaster is showing an incoming link as coming from four different pages: /, index.php, com_frontpage, and https. Three of these pages have different PR values, even though the content is identical. So not only is Google seeing them as different pages, but the PR is being diluted.

And I just saw the same issue on another site I maintain with index.php and /home showing as different pages. It's quite possible that in all of these cases other sites have linked to the individual variations, and that's how Google finds them. But the point that only one home page should be available to link to in the first place still stands.

sh404 resolves some of these issues, but not all. What surprises me is that I can't find a plugin to resolve this for simple sites that only need Joomla SEF. I'm hoping someone else knows of a solution like that which I've missed (or can post the relevant lines to add to htaccess, though those always seem to require more effort to maintain).

Re: Redirect /index.php permanently?

Posted: Wed Sep 02, 2009 12:02 am
by kavaXtreme

Re: Redirect /index.php permanently?

Posted: Wed Sep 02, 2009 12:42 am
by djohnson1215
kavaXtreme,

I feel your pain. In practice, all these URL examples (below) are distinctly different "logical" pages (even though they are the same "physical" page) in the world of http.

http://www.domain.com
http://www.domain.com/index.html
domain.com
domain.com/index.html

You could add https and get a few more variations of the same "physical" page.

This is the nightmare story for search engines. Theoretically, each of these URLs have the same hash value. And with the same hash value, search engines should be able to tell that they are aliases of each other.

Now - the problem. Lets say Google crawls and knows about each of these URLs. But the webmaster changes something. Google crawls one of the URLs and sees that the hash value has changed. Now one of the URLs has a mismatch to the other URL hash values. What does Google do? Do they spider the other URLs to see if they too have change hash values? I guess not (too many cpu cycles). And what happens if the webmaster makes another change before Google has time to check the other URLs? It's a problem. Does Google's Db go out of sync? May be.

The problem is the http protocol that allows one single "physical" page to be referenced different ways, by multiple URLs. It is a mess.

So SEO best practices are to help the search engines figure this out by applying 301 redirects to one of the URLs. The 301 redirect appears in the http header info. So Google and other SEs can understand that they need not waist their time (and cpu cycles) on a page that could be an alias of another.

So when you see lots of URLs of the same page in Google's webmaster account, Google is confused. They will ultimately sort it out, but in the mean time, they don't know where to assign the PR and which URL to rank. YUCK!

This story gets even deeper when you start to consider Google's Near-Duplication Content algo. But that discussion is for another day.

The moral of this story is: "Don't give the SE's a chance to get confused".

Google is going through a huge back-end update called "Caffeine". It is very possible that Google has some data synchro issues that take time to work through. If you have not put 301 redirect on 3 of the 4 URLs, do it. Then just wait for the "Google Love" to come your way. :-)

Hope this helped.

Re: Redirect /index.php permanently?

Posted: Sat Oct 10, 2009 2:18 am
by a2purn
The 301 permanent redirect helps the search engines figure this out. 301 redirects are applied at the host server level, not at the Joomla level. Therefore, you must log into your hosting control panel and look around for the redirect options. Be sure to use a 301 redirect and not a 302 redirect. Some control panels do not make this clear. So be careful. If you have questions, contact your hosting company for directions.
Thank for the info,
So, should we have to use a 301 also for https? currently we are using 302 by install redirect plugin after checked by above link checker i am using 302 redirect. and in the google toolbar shows 0 PR. is there any difference using https and without http.

Thanks. :o

Re: Redirect /index.php permanently?

Posted: Sat Oct 10, 2009 7:25 am
by hostmaster
Knalltrauma wrote:Hello everyone

I'd like to redirect the regular www.mysite.com/index.php permanently to www.mysite.com. The reason why to do this is, that e.g. the GoogleBot doesn't index both pages.

Does anybody knows, how to redirect it with a permanent 301?

Kind regards
:D
Both URL will be treated as different and can cause duplicate content issue, thus it is better to redirect 302.

Re: Redirect /index.php permanently?

Posted: Mon Oct 12, 2009 3:25 pm
by djohnson1215
hostmaster,

302 redirects are temporary redirects
301 redirects are permanent redirects

Google and webmasters alike recommend 301 redirects if you want the spiders to obey the redirect. Spiders will not obey a 302 redirect. It is 302 redirects that can cause dup content issues. 301 redirects will not.

This all assumes that the search engines do not figure out that www.mysite.com/index.php and www.mysite.com are aliases of one another. If they figure out that one is the alias of the other, then a 301 is just added protection against duplicate content and PR split issues.

Re: Redirect /index.php permanently?

Posted: Mon Oct 12, 2009 3:31 pm
by djohnson1215
a2purn,

I am not sure why you have https. Https is used for secure areas of your website. Typically, but not always, https is associated with an SSL key.

So, https should be separate from http portions of your website. In this case, you should NOT 301 redirect https with SSL keys to http pages.

BUT, it you have links from https pages to http pages, you should consider absolute addressing those links so they do not resolve to https pages. However, in the rare case that you can not absolute address http links on https pages, then use a 301 redirect to "break out" of the https scheme and back to http pages.

Hope this makes sense.

Re: Redirect /index.php permanently?

Posted: Mon Oct 12, 2009 3:59 pm
by a2purn
Thanks for your reply,
Actually i want the https is used for our separate pages only but why all our pages redirect to https, so now i break using https and use 301 redirect to http. i am affraid i have duplicate content by google.
should we have to remove redirect 301 https to http?
and how about bots will index again https if i remove it, since https for human only and http for robots,
would you please explain about robots no index https but http

Thank you

Re: Redirect /index.php permanently?

Posted: Mon Oct 12, 2009 8:18 pm
by djohnson1215
a2purn,

When you have an https page, and if links on that page have a relative address, then the linked pages will become https. For this reason, you should either:

1) use absolute address in your links on https pages (eg. http://www.domain.com/path/), or
2) 301 redirect the pages you want to be http from https pages.

Also, note that Joomla allows you to set each Joomla menu item to SSL enabled Off/Ignore/On. Select this option from Parameters (System). If you set to Off, a Joomla menu item on an https page should resolve to a http page (I think this is right). You may want to try this Joomla feature for Joomla menu items. If it works the way I think it works, then you will not need to 301 redirect Joomla menu item lined pages.

Re: Redirect /index.php permanently?

Posted: Mon Oct 12, 2009 8:32 pm
by a2purn
@djohnson1215

Thank you very much for your reply.
I can find it and running well from each menu that i want to set to https so that i have not to use redirect all pages to https.
once again thank you very much. :D

Re: Redirect /index.php permanently?

Posted: Mon Nov 30, 2009 12:37 pm
by CAD_designer
Just to add my experiences;

In order to redirect /home and /index to the root and return all non www addresses to www, I added the following to my .htaccess in the root of the /public folder;

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\."yoursite"\.co\.uk
RewriteRule (.*) http://www.yoursite.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.. [R=301,L]

a quick redirect check (i used searchmasters) shows redirects are working. However, i could not log in to the Joomla "back end" admin page. This was due to the code converting all urls to root. The admin page uses /administrator/index.php as a login url, therefore, the login page was returning blank.
A quick fix of this was to add the following exception to the code;
RewriteCond %{REQUEST_URI} !^/administrator

I now have a working (more) SEF friendly site, and can login as admin!
Hope this helps

Re: Redirect /index.php permanently?

Posted: Thu Jan 21, 2010 4:50 pm
by Hoegaarden
Thanks for that CAD_designer :)

I was having the same problem with the administrator section and couldn't figure out why until i traced my steps back to the index file redirect. I've implemented this it works fine.

However, i now have a problem because the site that I am working on has a search function and now the redirect has stopped this from working. When I removed the redirect though to see the URL of the search results, it doesn't have index.php in there. This has baffled me. :(

Anyone have any ideas?

Re: Redirect /index.php permanently?

Posted: Wed Mar 10, 2010 1:03 am
by misholini
I have experienced the same problem- the redirect causes the search module to fail

Re: Redirect /index.php permanently?

Posted: Wed Mar 10, 2010 3:53 pm
by hexagonsales
Found this code, added it to .htaccess:

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

worked straight away for me without any issues!

Re: Redirect /index.php permanently?

Posted: Thu Mar 11, 2010 1:13 am
by eok
my index.php doesnt want to dissapear, if I turn on mod_rewrite I have got Page not found.

maybe smth wrong inside .htaccess

#
# mod_rewrite in use

RewriteEngine On

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule (.*) index.php
#
########## End - Rewrite rules to block out some common exploits

# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)




RewriteBase /


########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

Re: Redirect /index.php permanently?

Posted: Thu Mar 11, 2010 9:07 am
by hexagonsales
Below you will see a copy of mine. Have a look and see if there are any major differences:

##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##

#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.hexagon-propertymanagement.co.uk/ [R=301,L]
Rewritecond %{http_host} ^hexagon-propertymanagement.co.uk [nc]
Rewriterule ^(.*)$ http://www.hexagon-propertymanagement.co.uk/$1 [r=301,nc]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /home\ HTTP/
RewriteRule ^index\.php$ http://www.hexagon-propertymanagement.co.uk/ [R=301,L]

########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)

# RewriteBase /

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

Re: Redirect /index.php permanently?

Posted: Thu Mar 11, 2010 5:18 pm
by Hoegaarden
Thanks for this. What i actually fixed this but can't remember how. Will go over the site again and post the solution on here.

Re: Redirect /index.php permanently?

Posted: Thu Apr 01, 2010 11:09 pm
by gabrieluk
Hi,
I'm having the same issue:
"Redirect /index.php permanently?"
As this topic is a big issue,and this post has gone wild with variations(https,etc...)I would like a final confirmation of the best practise to have only one homepage:www.mysite.com indexed by Google.
In my case, SEF is on,and i have:
http://www.mysite.com
http://www.mysite.com/index.php
http://www.mysite.com/home.html
So the best would be:

### re-direct home.html to root / ###
RewriteCond %{THE_REQUEST} ^.*\/home\.html\ HTTP/
RewriteRule ^(.*)home\.html$ /$1 [R=301,L]

### re-direct index.php to root / ###
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

Re: Redirect /index.php permanently?

Posted: Thu Apr 08, 2010 7:07 am
by Davidq
I am also having a problem derirecting I managed to do the site.com to www.site.com however icant get the index.php to work i ahve tried all of the above and it wont load the site I am hosting on godaddy
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\."site"\.co\.za
RewriteRule (.*) http://www.site.co.za/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.site.co.za/ [R=301,L]
RewriteCond %{REQUEST_URI} !^/administrator

Re: Redirect /index.php permanently?

Posted: Thu Apr 08, 2010 7:30 am
by Davidq
Ok I fixed it using three different suggestions from Joomla forum on Godaddy joom ver 1.5.15 sef yes and mod rewrite yes in config forwarded
trudyq.co.za to www.trudyq.co.za
trudyq.index.php to trudyq.co.za

so all will now be www.trudyq.co.za

code below fot .htaccess

Options +FollowSymLinks
DirectoryIndex index.php

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.trudyq.co.za/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} !^www\.trudyq\.co\.za
RewriteRule (.*) http://www.trudyq.co.za/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/administrator

Re: Redirect /index.php permanently?

Posted: Fri Apr 16, 2010 6:23 pm
by Averymedia
David's last post on this is a good start. Check your site on: http://www.searchmasters.co.nz/redirect-check/ to see if you are totally re-directed on all scenarios(html,htm,etc). Google likes to only have one.

There are some challenges in getting plugins to work when you redirect index.php, since the site is php based. I am still seeking out the answer (help?) as to whether or not .htaccess can be used, and if so what is the code? When I engage the index.php redirect, my client login plugin does not work however it redirects cleanly . I'm not that skilled in code. Anyone?

Re: Redirect /index.php permanently?

Posted: Wed May 26, 2010 12:14 am
by 092098jvm
Any solution for this one besides the .htaccess redirect? (which I'm sure will cause all sorts of problems down the road)

I like that Joomla adds the suffix for all of my sub-pages, but including the home page is a bad idea. I'm worried about duplicate content issues and it just doesn't look good. I can't think of any reason someone would want www.domain.com/index.php for a home page URL. ???

Re: Redirect /index.php permanently?

Posted: Mon Sep 06, 2010 9:56 am
by Davidq
I have always had the same issues, have a look at one of my sites www.rx-cash.biz and you will see that I fixed this using sh404 its the easiest way to fix this and they update their product often best money I have spent on any Joomla exstention. It will help you with redirect , duplicate content, etc it improved my alexa rank from 6 540 000 down to 3 829 142 in two weeks

Re: Redirect /index.php permanently?

Posted: Wed Sep 08, 2010 2:33 am
by Agelor
For a simple 301 redirect just add the following line in your .htaccess file:
redirect 301 /old-file-name.htm http://www.yourwebsite.com/new-file-name.htm

Re: Redirect /index.php permanently?

Posted: Fri Sep 09, 2011 12:45 pm
by jogesh_p
gabrieluk wrote:Hi,
I'm having the same issue:
"Redirect /index.php permanently?"
As this topic is a big issue,and this post has gone wild with variations(https,etc...)I would like a final confirmation of the best practise to have only one homepage:www.mysite.com indexed by Google.
In my case, SEF is on,and i have:
http://www.mysite.com
http://www.mysite.com/index.php
http://www.mysite.com/home.html
So the best would be:

### re-direct home.html to root / ###
RewriteCond %{THE_REQUEST} ^.*\/home\.html\ HTTP/
RewriteRule ^(.*)home\.html$ /$1 [R=301,L]

### re-direct index.php to root / ###
RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

hi i have the same issue but i don't know where i add the code for redirection??

here is joomla .htaccess codes
########## Begin - Joomla! core SEF Section
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
########## End - Joomla! core SEF Section

plz help to redirect the index.php, home.html to direct http://www.mysite.com