how do i hide index.php?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
HotelRoom2
-


Joined: 22 Aug 2006
Posts: 21

PostPosted: Mon Sep 25, 2006 6:58 pm    Post subject: how do i hide index.php? Reply with quote

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 View user's profile Send private message
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Mon Sep 25, 2006 7:16 pm    Post subject: Re: how do i hide index.php? Reply with quote

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 View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Mon Sep 25, 2006 11:52 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group