Re: Best way to do this: www.domain.com?page=var
| From: | tg-php at gryffyndevelopment dot com | Date: | Tue, 17 Jan 2006 15:54:21 +0000 |
| Subject: | Re: Best way to do this: www.domain.com?page=var | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-228716@lists.php.net to get a copy of this message | ||
If you can't set a new 'default page' on your server, using a header('Location:
...') will simulate the same thing.
I believe the web server sends an error "302" (like a "404" when page isn't
found) for saying that a page has moved and redirect the browser automatically to the new page.
So like I said, using an index.php containing a header redirect mentioned below is the equivalent of
setting a new default page on the web server... minus the "302" server response to the
browser.
I believe the original poster was trying to avoid creating a script whose only function was to
redirect (via javascript, php, or whatever) so I think the server default page thing is the best
solution here.
If you don't have access to that kind of configuration option, then a PHP header() script is a
close second choice.
I'd only use the javascript window.location or html meta-refresh techniques as a worst case
scenario.
-TG
= = = Original message = = =
I'm confused...
why does everyone use a refresh??? According to me, that's not what a
refresh is supposed to be used for (!). Why don't use a
header('Location: http://www.domain.com/start.php?page=home');
for it?
It's more in-line with RFC's
- tul
Ray Hauge wrote:
> You could also check to see if $_GET['page'] contains a value, and if it does
> not, then redirect it. Something like this:
>
> if($_GET['page'] == '')
> ~header("Refresh: 0; URL=http://www.domain.com/start.php?page=home"D
> (¿©ªëœ¤„5&/í&);
>
>
> Granted that isn't validating the $_GET['page'] variable input for security,
> but that should at least get you going. Also, that assumes that all your
> pages use the GET query to specify which page they are on. If that's just
> for the initial page, then you'd have to do some more qualification.
>
> HTH
>
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.