Page 1 of 1

How to get .phps working

PostPosted: 03. April 2011 07:16
by terminal10
hi

I have xampp installed in my windows...I want to display the php source code without executing it in browser

I have added the following line under <IfModule mime_module> in apache/httpd.conf

AddType application/x-httpd-php-source .phps

But it doesn't work...I get a 404 error...

how to get this working??

Re: How to get .phps working

PostPosted: 03. April 2011 07:48
by Sharley
This is enabled by default in 1.7.4 that I used for testing.

Tested in XAMPP 1.7.4 and *.phps is working fine with no need to do anything at all with any configuration file.

It is covered in \xampp\apache\conf\extra\httpd-xampp.conf file in this section
Code: Select all
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

My test was to change the extension of \xampp\htdocs\xampp\splash.php to splash.phps and load it in my browser using http://localhost/xampp/splash.phps and this was the result
Code: Select all
<html>
<head><title>XAMPP</title>
<link href="xampp.css" rel="stylesheet" type="text/css">
</head>

<body class=white bgcolor=#ffffff>
<center>
<img src=img/blank.gif height=180 width=1><br>
<!--
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
     codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
     ID=anim WIDTH=400 HEIGHT=100><PARAM NAME=movie VALUE="splash-swf.php"> <PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <EMBED src="splash-swf.php" loop=false quality=high WIDTH=400 HEIGHT=100 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT>
-->
<img src="img/xampp-logo.jpg">
<p>
<?php
    include("lang/languages.php");
    $i=0;
    while (list($key, $value) = each($languages))
    {
        if($i++)echo ' / ';
        echo '<a href="/xampp/lang.php?'.$key.'">'.$value.'</a>';
    }
?>
<p>
</center>
</body>
</html>
As opposed to the splash.php which gives the language selection screen for the XAMPP Demo Welcome page.

Test it using the above method and let me know if it is different for your but specify which XAMPP version you are using.

Good luck.

Re: How to get .phps working

PostPosted: 03. April 2011 07:52
by Altrea
in XAMPP 1.7.3 it is enabled too by default.

Re: How to get .phps working

PostPosted: 03. April 2011 07:56
by Sharley
@terminal10
Enabled by default even as far back as version 1.6.3a which is as far back as I can go at the moment. :)

Just checked the 1.7.5b1 and it is also enabled by default in this the latest version.

So it looks like it is available in just about all versions of XAMPP by default but give my test above a go and see if it works then check your own file and it's location path if you are getting a 404 file not found error.
The \xampp\apache\logs\error.log file may give more details about the 404 error message.

Re: How to get .phps working

PostPosted: 03. April 2011 08:58
by terminal10
thnx sharely for ur reply

i just installed the newer version of xampp i.e 1.7.4 but still not working....

i chekced in \xampp\apache\conf\extra\httpd-xampp.conf and the handler is correctly set as you have mentioned....

this is the error log:
[Sun Apr 03 13:20:34 2011] [error] [client 127.0.0.1] script 'C:/xampp/htdocs/xampp/splash.phps' not found or unable to stat

do i have to change any settings to make it work??

Re: How to get .phps working

PostPosted: 03. April 2011 09:05
by Sharley
What are you typing in the browser?

Copy the splash.phps into the htdocs folder and then type
http://localhost/splash.phps
Then see what happens and if possible paste here again the error.log entry.

Clear your browser's cache first (temporary Internet Files).

It works by default without changing anything but make sure you change the httpd.conf file back to where it was before you changed it.

Of course make sure that Apache and MySQL are showing a green running in the XAMPP Control Panel.

Re: How to get .phps working

PostPosted: 03. April 2011 09:18
by terminal10
If I am not wrong the splash.php that comes up after xampp installtion is inside htdocs/xampp folder.

So I am trying with that.. Also tried with index.php insise htdocs/xampp but not working


Error log
[Sun Apr 03 13:46:10 2011] [error] [client 127.0.0.1] script 'C:/xampp/htdocs/xampp/splash.phps' not found or unable to stat
[Sun Apr 03 13:47:42 2011] [error] [client 127.0.0.1] script 'C:/xampp/htdocs/xampp/index.phps' not found or unable to stat

Re: How to get .phps working

PostPosted: 03. April 2011 09:24
by Sharley
Please try and follow my instructions or we will be going no where fast.

Copy the splash.php from the htdocs\xampp folder to the htdocs folder.
Then rename the splash.php in the htdocs folder to splash.phps

Now type in the browser http://localhost/splash.phps

What happens now?

Re: How to get .phps working

PostPosted: 03. April 2011 09:30
by terminal10
got it :)

actually i am new 2 php so didnt understand dat i had 2 put both the source file as well as .php file together 2 make it...

thnx a lot Sharley for ur time

now can you tell me how to get some other extension to work like instead of .phps if i wanted .php123??