MyBB Community Forums

Full Version: index.php?whatever directs to my homepage?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi! I just realized that if I type any arguments into the adress, I don't get an error, but I remain on the page. That would not be a problem, maybe, but I had wordpress another forum software installed, and google indexed those non existing pages as my home page.

Example:

With smf I had this link:www.mysite.com/forumdisplay.php?fid=10 but this link does not exist anymore and when google came to crawl it , it indexed my homepage because www.mysite.com/forumdisplay.php?fid=10 shows as my homepage.

If I go to mysiste.com/pagedoesnotexist, I get a 404, which is good.

But if I go to mysiste.com/index.php?pagedoesnotexist it directs me to my homepage.

How can I redirect arguments that don't make any sense to a 404?

Thanks!
add to .htaccess
ErrorDocument 404 404.html

make a new 404.html file!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error 404 not found!</title>
</head>
<body>
<CENTER>
<font color="blue"><b>Error 404 not found!</b></font>
<a href="http://www.yourdomain.com" target="_self">Click here to return to forum</a></CENTER>
</body>
</html>
Hi! Thanks for answering. Unfortunately it didn't work. My webserver already serves a 404 page when there's nothing to be had.

The thing is that mysite.com/index.php?whateverparameter

or mysite.com/showthread.php?blahblahblahtotalrandomnonexistingurl is showing my mysite.com/index.php
So any parameter in url returns 200 instead of 404.

Bump.
you can great a custom .htaccess file here: http://www.htaccesseditor.com/en.shtml#a_errorPage
You could add <link rel="canonical" href="http://www.mysite.com/" /> to your index template.

That'd tell search engines it's identical to the main site www.mysite.com
I solved it, somewhat. Since smf passes the get parameters like this : index.php?parameters ,
in order point the nonexisting pages to a 404, I added this to mybb index.php:

if(($_GET)) header("Location: 404.html");

What this is saying : if index.php has parameters, redirect to 404.html

This is a hack and it wouldn't work if I would want to use smf. If I was using another cms and then switched to smf, it would have been the same.

I guess it's apache's fault thinking index.php?whatever us the same thing as index.php.

Oh, well, hope it helps somebody.