|
-
September 7th, 2002, 06:17 PM
#1
Custom file extension in PHP and Apache....
Ok, In this pretty much useless tutorial ill show you guys how to make any file extension work with PHP in Apache.... Would you like that index.yourname? 
Ok, First for the Windows Users.... Im assuming that you have Apache with PHP up and running.... If not check out Apache [http://httpd.apache.org] and PHP [http://php.net] for help....
Ok, Open your httpd.conf [C:\Program Files\Apache Group\Apache\conf\] by default and go all the way to the bottom.... If you installed PHP correctly you should see:
Code:
ScriptAlias /php/ "X:/path/to/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"
Now we need to add our own custom handler... For this example I'll Add index.ac1d as a file for PHP to parse....
Code:
ScriptAlias /php/ "X:/path/to/php/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .ac1d
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .phtml
Action application/x-httpd-php "/php/php.exe"
Ok, Now that we have that set up we need to edit DirectoryIndex to read index.ac1d as the index file for each directory on your server =)
Before
Code:
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
...and After
Code:
<IfModule mod_dir.c>
DirectoryIndex index.ac1d index.html index.php
</IfModule>
Now, Go to your webservers root Directory [htdocs] and make a index.yourfileext with the following contents:
PHP Code:
<?php
echo "w00t! PHP works with the custom extension!";
?>
If that works, You got it.... If not go back and see what you did wrong 
For Linux users:
First of all install apache_devel, php, and mod_php.... Then add this line to the end of the loading scripts in httpd.conf (If you have not already done so)
Code:
LoadModule php4_module modules/libphp4.so
Then somewhere below that add the following
Code:
AddModule mod_php4.c
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php .yourext
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .phtml
</IfModule>
Change the DirectoryIndex as with the Windows Part of this tutorial, Make the file.... And your done =)
-
September 7th, 2002, 08:50 PM
#2
Senior Member
* Alex wonders why no one replied to his tut
hehe well heres a response, nice info alex
what is love but contempt for hate?
-
September 7th, 2002, 09:42 PM
#3
Ahhhh, 
Thanks indolent
-
September 7th, 2002, 09:48 PM
#4
Junior Member
Alex another great tut.... keep it up man
-
September 7th, 2002, 11:19 PM
#5
You can also do that in .htaccess, but doing it that way is much more simple.
-
September 7th, 2002, 11:22 PM
#6
Great tutorial dude! Yeah, when you were teaching us that in IRC, I was like so happy. It is a great tutorial that, IMO, is a cool subject. Good Job! -- Jason Copeland
P.S : Keep up the great tutorials
-
September 8th, 2002, 01:53 AM
#7
Well, if you want a reply, you get one !!! The tut is very cool (and useless to most, but who cares ) and well I already told you this... Good tut !!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|