Hello to all,

I had this habit several years ago to link to my site using both http://www.example.com/ and http://www.example.com/index.php. That was many years ago (about 10) way before I started using Drupal on all my websites.

Now Google seems to be penalising my site for duplicate content, as it has indexed both versions.

I am trying to redirect using the following code in my .htaccess:

RewriteBase /
RewriteRule ^index.php$ http://www.example.com [R=301,L]

However when I do this (it works) the login system stops working (I can't login) and I can access the account only via the reset password option. Also when I add the above code the clean urls stop working.

Any ideas on how to achieve this redirection?

Thanks in advance,
Pavlos Skoufis

Comments

pavlos’s picture

For future reference...

I added this to the page-front.tpl.php... Running on Apache...


if ($_SERVER['REQUEST_URI'] == "/index.php")

{

header('HTTP/1.1 301 Moved Permanently');

header("Location: http://www.example.com");

exit();

}

sujoyit2005’s picture

Though the code is not very elegant, as we are putting logic in template files, where only html's should be printed, but its good tip and working fine!

Also, we can use the https://www.drupal.org/project/globalredirect drupal module for only the "Frontpage Redirect Handler" option from this module's configuration page.