Echo the difference between '/' and '/index.php'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Echo the difference between '/' and '/index.php'

Post by elHelgo »

For some reason, my site lags when it runs "www.website.com", but loads just fine when it runs "www.website.com/index.php"

Is there a way that I can tell if the URL has the "index.php" in it or not?

I've tried to use the predefined variables REQUEST_URI, SCRIPT_NAME, SCRIPT_FILENAME, and PHP_SELF when I'm on "www.website.com/", but all of these return an index.php in the variable.

The goal that I'm trying to achieve is that if PHP can recognize "www.website.com/", I want to use headers to make it go to "www.website.com/index.php"

Any help on this would be greatly appreciated.

Thanks.
Last edited by elHelgo on Tue Jul 31, 2007 10:25 am, edited 3 times in total.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

You should try to find out why it is lagging and fix that problem instead.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

The webserver sounds like it's been set up to make "index.php" a default index page. Webservers can't display "/" - they need a file to show. So, in this instance, the server is showing "index.php".

I'm with ~Begby - try and figure out why "/" is slow but "/index.php" is not slow. If it's a consistent problem, I'd check the configuration of the server software (I'm guessing Apache?)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Post by elHelgo »

I know that there is something wrong with the host and/or server, but I was trying to find a quick fix for the problem. I did find one through trial and error, and was wrong about the REQUEST_URI output.

Simply enough, I just did this:

Code: Select all

if ($_SERVER['REQUEST_URI']=="/"){
  header("Location: newsite.com");
}
Hopefully this will buy me enough time to debug my other problems in life.
Post Reply