Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: ocean10000

Message Too Old, No Replies

301 Redirect from index.php to /

Help redirecting index.php to / on windows server

     
11:52 am on Feb 12, 2009 (gmt 0)

New User

10+ Year Member

joined:Feb 12, 2009
posts: 3
votes: 0


Hi

I have a site running on a Windows server (IIS) which is currently being optimised. The SEO guys have recommened that i set a redirect for ***.domain.com/index.php to forward to ***.domain.com/ as Google is indexing ***.domain.com and ***.domain.com/index.php as seperate entities.

All the 301 redirects done previously have been done in IIS through the permenant redirection tool in the Home Directory tab for the site profile. If i do this for the index.php (to permenantly redirect to ***.domain.com) then its going to get stuck in an infinate loop as IIS is loading index.php by default which in turn is redirecting back to ***.domain.com and so on. Obviously removing the default document type is just resulting in directory listing.

Can anyone help with how i may be able to achieve what they are asking? Im pretty stumped.

Thank you in advance.

10:30 am on Feb 13, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 19, 2006
posts:92
votes: 0


You need to something like:

$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];

if($host == 'example.com' ¦¦ $uri == '/index.php') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
}

11:38 pm on Feb 17, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Aug 30, 2007
posts:690
votes: 6


Would this not work? in the head code of the page
<META http-equiv="refresh" content="0;URL=http://www.example.com/index.html">

[edited by: encyclo at 7:36 pm (utc) on April 10, 2009]
[edit reason] exemplified [/edit]

10:51 am on Feb 18, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 19, 2006
posts:92
votes: 0


No, as the meta tag will be present on both the .com and .com/index.php pages, unless you use an if statement to conditionally add the meta tag, on the backend. But then, why force the browser to download a page only to then find out it must redirect.

Also, the meta method doesn't allow the status code to be set in the header i.e. 301...

10:08 pm on Mar 6, 2009 (gmt 0)

New User

10+ Year Member

joined:Aug 11, 2008
posts: 2
votes: 0


So will this code work if we're working in ASPX? (i.e. index.aspx?

$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI'];

if($host == 'example.com' $uri == '/index.aspx') {
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
}

Cheers

4:29 am on Apr 10, 2009 (gmt 0)

New User

10+ Year Member

joined:Oct 12, 2006
posts:5
votes: 0


I would handle the redirect through ISAP rewrite plugin
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members