Click to See Complete Forum and Search --> : Make php scripts work on .html pages...
BigMoosie
04-20-2005, 01:40 AM
I would like to know how to make a php script work on a .html page. When I try to do that at the moment it doesn't execute the code and it appears in the actual source that the client receives. Is this possible?
Also, if it is possible, to make a php script work on a page without a suffix. It must be possible because the google search is www.google.com/search?q=moose...
Thanks alot.
- Big Moosie.
ShrineDesigns
04-20-2005, 02:57 AM
add this to a .htaccess file or if this is your server make the changes in your apache's httpd.conf fileAddType application/x-httpd-php .htm .html
BigMoosie
04-20-2005, 03:06 AM
Thanks shrine,
ok, i am just starting with PHP, Im quite good at javaScript and it looks all the same so i think i will pick up on it quickly but what is a .htaccess file? can it just be an empty file in the main directory with nothing but that line?
BigMoosie
04-20-2005, 03:17 AM
Hmmm, never mind, got the results i needed from google. but this does not seem to work, any ideas why? i created a file named .htaccess that i made with notepad with that line. should be working shouldnt it?
scragar
04-20-2005, 03:21 AM
to make a file work without an extension the most common method is to make that file name a folder, and have it as an index file within that folder.
and a .htaccess file is handeled by the server and is used to inform it of any extra things it must consider before returning the page, shrine had it proccess html and htm files as PHP, but it can also be used to request a password, redirect the user or completely change the content(like all these nice sites that ban external image hosting)
EDIT: commonly the file must be created by the server so it knows to read it, although downloading them and uploading them can also work.
BigMoosie
04-20-2005, 03:51 AM
thanks scragar, if i make it a directory then i wont be able to make paths like:
www.mysite.com/about?q=asdfasdf
plus it will add a forward slash at the end which for reasons not necessary to discuss.
I have done some reading and it seems I need apache for this?
I have created a page at the following: http://www.abrahamjoffe.com.au/pass.php
All it has is: <?php phpinfo(); ?> so can somebody tell me if I can use .htaccess with this server please? Thanks alot
scragar
04-20-2005, 03:57 AM
I think the use of htaccess is hard built into appache, I'll make one for my site and provide the URL, you can download it and upload it again, then see if it works.
BigMoosie
04-20-2005, 04:20 AM
Thanks scragar, but I'm not sure that apache is installed, if PHP is does that automatically mean apache is?
scragar
04-20-2005, 04:26 AM
no, but appache is most common, and after all it's only a test.
I couldn't set up my own .htaccess file for you though, my host just keeps throwing out there custom error message:
"Unknown server error. Our staff have been informed and we hope to fix this problem soon, sorry for any problems this may cause."
Stupid server.
BigMoosie
04-20-2005, 04:29 AM
Oh, hope that sorts itself out, thanks for helping me though. If I am still stuck in a few days I will try to obtain more help but in the meantime I should be able to solve the problem myself.
Thanksalot!
scragar
04-20-2005, 04:40 AM
the most anoying thing about my servers error is that untill adding the custom message it had never come up with an error...
And I've just found an article on how to do what you wanted with the no extension files, but it's done in .htaccess still, if you can get htaccess set up some how then I'll post a copy up here OK?
BigMoosie
04-20-2005, 05:51 AM
i dont know if i will be able to get .htaccess working, i dont think that this is an apache server, is there a Windows 2003 Server? Well, here are the details of the server: http://www.studiocoast.com.au/hosting.asp and there is no mention of apache anywere. What would I have to do in this case?
scragar
04-20-2005, 06:54 AM
windows understands it as well. but many ones like sunsoft are unable to(although most major OS's understand it).
I recomend asking the support staff to set it up for you, after all they guarentee satisfaction.
bokeh
04-20-2005, 09:58 AM
Hi!AddType application/x-httpd-php .html .htm .php only works if you are not using mod_rewrite. to make a file work without an extension the most common method is to make that file name a folder, and have it as an index file within that folder. Although that works these days that is handled by an apache module and no trailing slash is displayed.
Problems arise though when a file and a directory share the same name.
Have a look here (http://www.bugster.co.uk/bugeye) and here (http://www.bugster.co.uk/bugeye.htm) both go to the same file but one without the extension. By the way there is no .htaccess file and no mod_rewrite rules in httpd config files so I'm not certain how it works. I had mod_rewrite on another server but it didn't do this.