Setting up Apache 2: .php-extensions

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Setting up Apache 2: .php-extensions

Post by Derfel Cadarn »

I just installed Apache-PHP-MySQL on my new computer. Since the last time was quite a while ago, I have forgotten a few details.

When I want to visit phpinfo.php on my localhost, I need to type: "http://localhost/phpinfo.php". But I know it's possible to set up the Apache-server so I can type "http://localhost/phpinfo", that is without the '.php-extension'! I just forgot how to do it :oops:

It's probably some setting in the http.conf-file, but I cannot find it!

Any ideas??
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

you have to put it in a php file..

in other words, create a file called "mypage.php"

in that file, put this line of code :

Code: Select all

<?php
phpinfo();
?>
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Hi Infolock,

thanx for the reply, but I'm afraid I didn't make myself clear (apparantly).
I was playing with the highlight()-function and the script shown on php.net. As php.net told, I added this to the httpd.conf-file:

Code: Select all

&lt;Location /source&gt;
    ForceType application/x-httpd-php
&lt;/Location&gt;
and then created a script containing this code:

Code: Select all

<html>
<head>
<title>Source Display</title>
</head>
<body bgcolor="white">
<?php
   $script = getenv("PATH_TRANSLATED");
   if (!$script) {
       echo "<br /><b>ERROR: Script Name needed</b><br />";
   } else {
       if (ereg("(\\.php|\\.inc)$", $script)) {
           echo "<h1>Source of: " . getenv("PATH_INFO") . "</h1>\n<hr />\n";
           highlight_file($script);
       } else {
           echo "<h1>ERROR: Only PHP or include script names are allowed</h1>";
       }
   }
   echo "<hr />Processed: " . date("Y/M/d H:i:s", time());
?>
</BODY>
</HTML>

?>
As said on php.net, I stored it as "source" in the apache-rootdirectory.
PHP.net says:
Then you can use an URL like the one below to display a colorized version of a script located in "/path/to/script.php" in your web site.

http://www.example.com/source/path/to/script.php
but that doesn't work for me! I need to store the file "source" as "source.php" and then I can use it like this:

Code: Select all

http://www.example.com/source.php/path/to/script.php
But I remember I had it setup (once upon a time) so that I could use it with:

Code: Select all

http://www.example.com/source/path/to/script.php
And THAT's what I want to be able to do again! Do you understand what I mean here?
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

* bump *

Anyone? Please?
:cry:
User avatar
Derfel Cadarn
Forum Contributor
Posts: 193
Joined: Thu Jul 17, 2003 12:02 pm
Location: Berlin, Germany

Post by Derfel Cadarn »

Aarghh
<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> it! :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted: :twisted:
Post Reply