Re: naming file
| From: | (Richard Lynch) | Date: | Thu, 22 Jun 2000 03:42:17 +0000 |
| Subject: | Re: naming file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2573@lists.php.net to get a copy of this message | ||
In article <01bfdb7a$5b6b8790$d3f80e0a@psd_server.stttelkom.ac.id>,
ste94034@stttelkom.ac.id ("Eris Ristemena") wrote:
> hi all,
> is it possible to name a HTML file using PHP ? i usually see the HTML file
> with something look like this 00,12,34-01001.html
> they told me that it uses php, can someone tell me this ?
You can name a file any damn thing you like, and (using Apache) easily
convince Apache that it's a PHP file.
To just get the extension (.html) recognized as a PHP file, edit your
httpd.conf file, and find the line that mentions php and has AddType in
it. Put html at the end of it, just like the php that's already there.
It will look something like:
AddType application/x-script-php php html
when you're done, except I can never remember if it should be .php .html
or not, and the mime type is somewhat arbitrary, so just leave it alone.
(It has to match the mime-type specificed elsewhere in httpd.conf)
If you can't *edit* the httpd.conf file, because you're on an ISP, you can
probably *read* it, and then put an AddType line just like the PHP one in
a file named .htaccess in your directory, and change the php extension to
html there. (Both AddType's will be in operation then.) In that case,
you'll have just this in your .htaccess file:
AddType application/x-script-php html
Of course, you may want to add htm as well, or even asp or jsp to really
confuzzle things.
Note that this means that PHP will then be parsing *ALL* html files in
your directories, and that does slow down your html files by like maybe
5%. So if it's not worth 5% to be cool, or to have URLs that even
musicians can remember (my scenario) don't do it.
As far as the usage of the numbers and commas to pass data into PHP go,
there's an excellent article out there, whose URL I always forget about
"Rewrite and PHP" (type that in your fave online search engine). Again,
you'll need to dink around with Apache's httpd.conf file (or .htaccess
file) to do the Rewrite stuff.
A really short explanation is that you are going to convince Apache to
"rewrite" a URL like "00,12,34-01001.html" into
"yourpage.php3?00,12,34-01001", and then in PHP, you use $path_info (or
whatever variable shows up in phpinfo() that's handy) to tear apart all
those numbers and do whatever you want with them.
The Rewrite stuff is documented in excruciating detail at http://www.apache.org/
Presumably this could be down with IIS as well if anybody actually
understood IIS. Just don't ask me how.
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)