Jump to content

.php extension change in browser


David Nelson

Recommended Posts

Hey guys,

 

For a special project I'm doing I need a .php page to show up as either a different extension in the address bar or no extension at all (i.e., right now it is search.php?action=XXXXX, I want it to be simply search?action=XXXXX) or something to that extent.

 

Do I need to do something with my server mime types or what?

 

Thanks!

Link to comment
Share on other sites

PHP on Windows sucks....because of Windows. And especially in CGI mode.

 

Also....

 

http://youdomain.com/?pid=2&search=12

 

Simplified example..

"index.php"

<?php

function getContent() {

  $pageID = $_GET['pid'];

  switch($pageID) {
    case 2:
      Search($_GET['search']);
    break;
    
    default:
      mainContent();
  }

}

function mainContent() {
  //Whatever dude. Load a template file or add your HTML here.
}

  getContent();


?>

 

Instead of using/linking to a million diferent PHP files...just use functions or even include files and add some kind of conditional statement that determines what content to load. Technically, you don't need to have the extension in the url. Apache mod_rewrite would be much nicer than this though.

Link to comment
Share on other sites

Post to any given page (i.e. post.php).  Then when finished processing redirect back to the folder page with a get var so that page knows if the processing was successful.  You'd redirect with the command:

 

header("Location: ../dir/?command=success"); // if successful, or command=fail if failed.

 

Really simple example but the idea should work.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.