poil11
06-22-2001, 01:14 PM
i am looking to parse php in html file .html .shtml how do i got about doing this? in http.conf i put the line.
AddType application/x-httpd-php .php .html .shtml .phtml .php3
also how do i make it so when i call a php file named bleh.com/file.php i can call it via just bleh.com/file/
anyways, i did the above and restarted apache and it didn't work. i am on the freedom 400 accoutns on hostpro if that is any help.
To answer your first question, it looks like you have the correct format. For example, in my httpd.conf file, I have:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html .phtml
(it's not two lines for any real reason). This setup will let me parse php in files that end in .php, .html, and .phtml. Be careful about parsing php in files that end in .shtml. This is used typically for SSI files, and whereas I don't know if also making it parse php will screw it up, it may.
In answer to your second question, you can just put the files names to your DirectoryIndex option in httpd.conf to let apache run it automatically when going to that directory. For example, if you wanted index.html or index.php files to be run when going to a directory, put in the following line:
DirectoryIndex index.html index.php
Note that it will read them in order they are entered, so if you had both an index.html and index.php file present, it will use the index.html file since that was first.
Of course - be sure to restart Apache! No changes you make will take effect until you restart Apache.
Finally, and I hope this is not insulting, but be sure that PHP is compiled into your Apache install. :) You can check the modules installed by typing in the path to the apache binary with a -l (that's "L" as in Lucy) after it. Here is my config:
/usr/local/apache/bin/httpd -l
Compiled-in modules:
http_core.c
mod_env.c
mod_log_config.c
mod_mime.c
mod_negotiation.c
mod_status.c
mod_include.c
mod_autoindex.c
mod_dir.c
mod_cgi.c
mod_asis.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_rewrite.c
mod_access.c
mod_auth.c
mod_so.c
mod_setenvif.c
mod_php4.c
So you can see that php4 is installed (last line).
Hope that helps.
freakysid
06-22-2001, 05:25 PM
To make bleh.com/foo resolve to bleh.com/foo.php you can have all requests to your domain handled by a gatekeeper script. There are a couple of ways of doing it:
1) A cludge, but make a custom 404 page that is a script that gets called when Apache cannot find the ellusive "foo" in the doc root. The script can then look at the REQUEST_URI and send a redirect header to the appropriate page/script.
2) Use mod_rewrite to create a rewrite rule that does the same as above. All requests for domain bleh.com go to a specific script that redirects according to the value of REQUEST_URI
Or instead of sending a redirect - you could just suck the appropriate page into the index/gatekeeper script by way of an include("foo.php").
Bleh - even easier, just use a rewrite rule to append the .php onto the REQUEST_URI!