re-direct domain.com/index.php to domain.com

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Scam Warning
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
User avatar
haggisv
Registered User
Posts: 261
Joined: Wed Dec 20, 2006 3:31 am
Location: Adelaide, Australia
Contact:

re-direct domain.com/index.php to domain.com

Post by haggisv »

For SEO reasons it's better not to have a homepage at both domain.com and domain.com/index, but just have one or the other. phpbb seems to internally use the domain.com/index.php, but most external links (many of which you don't have control over) tend to point to just domain.com.

What's the easiest way to resolve this?
Peter77sx
Registered User
Posts: 3260
Joined: Wed Nov 09, 2005 2:51 pm

Re: re-direct domain.com/index.php to domain.com

Post by Peter77sx »

You can use Canonical URL to let the major search engines know which one you prefer.
A nice MOD for this is here http://www.phpbb.com/customise/db/mod/canonical_url/ also works with your forum's pages viewtopic, viewforum. simple and light.
User avatar
/a3
Registered User
Posts: 411
Joined: Sun Sep 19, 2010 9:08 am
Location: /dev/random

Re: re-direct domain.com/index.php to domain.com

Post by /a3 »

You could also do the following:

Open includes/functions.php
FIND:

Code: Select all

'U_INDEX'				=> append_sid("{$phpbb_root_path}index.$phpEx"),
REPLACE WITH:

Code: Select all

'U_INDEX'				=> append_sid($phpbb_root_path),
That means the board will always link to / instead of /index.php.

Also, if you have access to .htaccess you could change the default directory to /index2.php instead of /index.php, and then make /index.php redirect to /. So that way all board index links in the future will redirect to /.

In .htaccess, do something like:

Code: Select all

DirectoryIndex index2.php index.htm index.html
And in /index2.php use the following:

Code: Select all

<?php
/* no point in doing anything too complicated! */
$phpbb_root_path = './';
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $phpbb_root_path);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Page Moved</title>
</head>
<body>
<h1>Page Moved</h1>
<p>This page has been moved! Go to the <a href="<?php echo $phpbb_root_path; ?>">Board Index</a>.</p>
</body>
</html>
$ git commit -m "YOLO"
User avatar
haggisv
Registered User
Posts: 261
Joined: Wed Dec 20, 2006 3:31 am
Location: Adelaide, Australia
Contact:

Re: re-direct domain.com/index.php to domain.com

Post by haggisv »

Thanks a lot guys, I will try that!
Locked

Return to “[3.0.x] Support Forum”