View previous topic :: View next topic |
Author |
Message |
HotelRoom2 -
Joined: 22 Aug 2006 Posts: 21
|
Posted: Mon Sep 25, 2006 6:58 pm Post subject: how do i hide index.php? |
|
|
i'm writing a script that hides the index.php? part of the requested url, so when someone request a page the url with the index.php? part it will redirect to /?page=whatever, instead of /index.php?page=whatever and do it's thing but firefox reports it's redirecting improperly.. when i try this technique i'm fairly new to php.. so i need a little help
Code: |
<?php
$page = $_GET['page'];
$hidephp = 1;
If ( ($hidephp == 1) && (strpbrk("index.php?",$_SERVER['REQUEST_URI'])) ) {
header("Location: .?page=$page");
}
echo $_SERVER['REQUEST_URI']; //a little debuging
?>
|
|
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Sep 25, 2006 7:16 pm Post subject: Re: how do i hide index.php? |
|
|
Whats the full stop for?
Code: | header("Location: .?page=$page"); |
The php documentation for strpbrk() suggests to me that strpbrk() might not be suitable for the use that you are putting it to. (But then I could be wring!)
Another suggestion might be to add the full url address to the redirect, minus the "index.php", you can get this from the referer environment variable $_ENV["HTTP_REFERER"] (I think that is what it is from the top of my head!) _________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Mon Sep 25, 2006 11:52 pm Post subject: |
|
|
You need to start the path in the Location header with a forward slash. I use
this method for my "Powered By Abyss" database website.
Example:
Code: | <?php
$page = $_GET['page'];
if (!empty($page)) {
header("Location: /?page=$page");
exit;
}
else {
echo "Please enter a valid page value.";
}
?>
|
|
|
Back to top |
|
|
|