link to PHP page without using .php extension in link

I have a PHP page which captures some information from a user, but when I print the link on a poster for a promotional piece, I do not want to have to have written ".php".

Is there a way to link to this php page without the extension  explicitly written: "www.website.com/form" instead of "www.website.com/form.php"

When I enter it in my browser without the extension, the page cannot be found.

Thank you so much for your help!
hibbsusanAsked:
Who is Participating?
 
bklyn2001Commented:
you could rename the file index.php and put it in a directory so that by default it would open that file.  for example:

www.website.com/dirname

where dirname is the directory containing the index.php file.
0
 
jessc7Commented:
I think bklyn2001's suggestion is the simplest, but you might also look at this post if you plan on modeling this out on multiple files:

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_26303426.html
0
 
leakim971PluritechnicianCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Ray PaseurCommented:
I have just done exactly this thing for my church.  We used a PHP solution to add a 404 handler.  When the page is not found, it will be retried with the .php suffix.  You can see how it works here:
http://www.NationalPres.org/cares 
<?php // nationalpres.org/404handler.php
error_reporting(E_ALL);

if (isset($_SERVER["REQUEST_URI"]))
{
    // IF A PHP SCRIPT IS NOT FOUND GO TO THE HOME PAGE
    if (preg_match('#\.php#i', $_SERVER["REQUEST_URI"]))
    {
        header('Location: /');
        exit;
    }

    // IF A NON-PHP SCRIPT IS NOT FOUND, TRY IT WITH PHP
    $arr = explode('?', $_SERVER["REQUEST_URI"]);
    $arr[0] .= '.php';
    $uri = implode('?', $arr);
    header("Location: $uri");
    exit;
}

// IF NO REQUEST URI
header('Location: /');
exit;

Open in new window

To make this work, we use the following .htaccess file:
ErrorDocument 404 /404handler.php

HTH, ~Ray
0
 
hibbsusanAuthor Commented:
Ray_Paseur,

I understand the basic gist of what your code is doing, but I do not understand where I should put it. I have the same question here:

To make this work, we use the following .htaccess file:
ErrorDocument 404 /404handler.php

Is ErrorDocument 404 /404handler.php an .htaccess file? Or is it a line with which I should modify an existing file with?

Thanks!
0
 
Ray PaseurCommented:
It goes in the .htaccess file. All on one line.
0
 
hibbsusanAuthor Commented:
such a simple solution. it worked perfectly. thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.