MyBB Community Forums

Full Version: index.php redirect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

My site is suffering from "Pagerank Leak" - www.myurl.com/index.php has a higher pr than www.myurl.com.

Is it possible that, if a user enters the site via www.myurl.com/index.php for them to be redirected to www.myurl.com?

Thanks Smile
Try to edit you .htaccess
add

Redirect /index.htm http://your_domain.com/

or
Redirect permanent /index.htm http://your_domain.com/



regards
The only problem is that MyBB uses the file for a few things like collapsing forum categories, if I redirect them it causes a lot of problems. I tried it once and it put the system in an endless loop of redirection.
header("Location:http://www.myurl.com/"); in your file Smile
ops I missunderstood. however you could do an ugly hack.
if($_SERVER['REQUEST_URI'] == "index.php") { header("Location:http://www.myurl.com/"); exit; }
However only works if the request_uri is on the main domain. like myurl.com/new doesen't work on the code I posted.
ooh then you can just do
if($_SERVER['REQUEST_URI'] == "new/index.php") { header("Location:http://www.myurl.com/"); exit; }
or something ^^
I tried the code, but when I go to index.php it dosen't redirect to the homepage Sad
try this then.

if(stristr($_SERVER['REQUEST_URI'], "index.php")) { header("Location:http://www.myurl.com/"); exit; }

however, works for me. Smile
Sorry if this is a stupid question, but what's the difference? Aren't they the same thing...?
no, stristr searchs for index.php in the requested uri, however, the first one just checks if request uri is index.php.

and if that doesen't work you can always change stristr to strripos Smile
CraKteR: Thank you very much!
The second snippet you posted works fine.

Thanks again!

Belloman: For some reason, www.myurl.com/index.php has a PR of 5 and www.myurl.com has a PR of 4. I'm trying to have the PR5 on the main URL. Hopefully this will prevent people linking to index.php, plus Google should notice the redirect
No problem, happy to help Smile