Page 2 of 3
Posted: Wed Dec 14, 2005 4:33 pm
by mikeycorn
It's shared hosting. I got off the phone with tech support, after putting me on hold four or five times I was finally given a definate assessment that there was no way to customize how the php handler for your site.
I can't find .htaccess anywhere from the root down, either.
This isn't normally the case though, right? I mean, even if you're sharing the server, don't most webhosts give you a chance to tweak your PHP configuration?
Posted: Wed Dec 14, 2005 4:48 pm
by John Cartwright
Most likely you do not have an .htaccess, and they should be place above the webroot, not below which is where you were searching for it. Open open a text editor and save it as .htaccess. You can use the .htaccess file to manipulate the httpd.conf values.
This isn't normally the case though, right? I mean, even if you're sharing the server, don't most webhosts give you a chance to tweak your PHP configuration?
On a shared host, this is usually the case, unfortunantly.
Posted: Wed Dec 14, 2005 4:50 pm
by redmonkey
It's all down to the individual host, some allow for more configuration than others. In a lot of cases using ini_set() will cater for most of the PHP config tweaking that you are likely to reuire (of course this won't help for your problem though).
.htaccess files are not created by default. I'd suggest you google round for some example uses of .htaccess which should help determine if A) you can make use of .htaccess and B) which directives (if any) are available to you.
Posted: Wed Dec 14, 2005 4:54 pm
by mikeycorn
Damn, I ain't paying $99/month just so I can get some php parsing out of my html files. I finally just went with the redirect solution, although I found this article which gave a few more options after the meta tag solution:
There are a number of ways of redirecting. Here are the two main ones:-
The Meta Refresh Tag
<meta http-equiv="refresh" content="5;url=
http://domain.com/page.htm">
This tag, which should be placed in the HEAD section of the redirecting page, tells the browser to refresh the page by loading the stated URL. The "5" tells the browser to do it 5 seconds after loading.
Nobody is against this method as long as the number of seconds delay is sufficient for the surfer to see the page and to be able to read some of it. A typical use is after posting a message in a forum where the poster is given a confirmation page that, after a few seconds, automatically returns to the forum.
However, some people question this method when the delay is set to 0 (immediate) or a tiny number of seconds. I have shown that there is nothing whatsoever wrong with an immediate redirect. I have shown that search engines are happy to do it, and I have shown that people want to go to what the link text tells them is at the other end - without any delays. There are valid reasons to set the delay to 0. Setting it higher than 0 and delaying the surfer en-route, for the sake of making some silly people happy, is just plain stupid.
Javascript Redirect
<script language="javascript"><!--
location.href="url"
//-->
</script>
where url is the full or relative URL of the page to redirect to.
Better still is the following script:-
<script language="javascript"><!--
location.replace("url")
//-->
</script>
In this case, the redirecting page is not retained in the browser's History, and the Back button goes to the page before the redirecting page, thereby avoiding that awful trap where clicking the Back button takes you back to a redirecting page, which immediately redirects you forward again to the page you want to leave.
The above is a typical example of an immediate redirect to the specified URL. If the script is placed in the HEAD section at the top of the page, the redirection occurs straight away, otherwise it may take a short time for the page to render before the browser even realizes that the script exists.
If required, the script can be stored in an external file and loaded by the following line, where "filename.js" is the path and name of the external file:-
<script language="JavaScript" src="filename.js"></script>
Actually, the switch was so quick as to be inperceptible to the user, so it wasn't a bad solution in the first place.
Still, I learned a lot from this thread so thanks a bunch to both of you for helping educate a server side newbie.
Posted: Wed Dec 14, 2005 5:19 pm
by RobertGonzalez
Just understand that if you use the JavaScript method of redirecting you are assuming your user has JavaScript enabled in their browser. If they don't, you may want to have some form of content in the index.html page that allows them to move beyond the page. Something along the lines of "If this page does not automatically redirect you, click here" type thing.
Just an FYI.
Posted: Wed Dec 14, 2005 5:40 pm
by trukfixer
if you have Server Side Includes enabled, you can include a php script into a .html file - the include will execute the php script and put its output into wherever you put the SSI include.. but again, some webhosts dont allow that ..
$99 a MONTH for webhosting?? You're kidding, right? You could get a dedicated server for that much
otherwise- you either have to redirect, or if it is enabled, a .htaccess directive can be used to AddHandler to parse .html as php
(It's known as mime types - Ive done it before- using my own made-up extension - index.stupid which was parsed as php

- if you have a CPanel control panel, this may be one of the options you are provided- if it is enabled, you can edit mime types )
Posted: Wed Dec 14, 2005 5:59 pm
by RobertGonzalez
Wouldn't using SSI require the extension to be changed to .SHTML? That would be the same thing as using index.php in a way.
Posted: Wed Dec 14, 2005 6:24 pm
by mikeycorn
Everah wrote:Just understand that if you use the JavaScript method of redirecting you are assuming your user has JavaScript enabled in their browser. If they don't, you may want to have some form of content in the index.html page that allows them to move beyond the page. Something along the lines of "If this page does not automatically redirect you, click here" type thing.
Just an FYI.
I never really got why they put up that message. Now I know. Good tip, thanks.
trukfixer wrote:if you have Server Side Includes enabled, you can include a php script into a .html file - the include will execute the php script and put its output into wherever you put the SSI include.. but again, some webhosts dont allow that ..
$99 a MONTH for webhosting?? You're kidding, right? You could get a dedicated server for that much
otherwise- you either have to redirect, or if it is enabled, a .htaccess directive can be used to AddHandler to parse .html as php
(It's known as mime types - Ive done it before- using my own made-up extension - index.stupid which was parsed as php

- if you have a CPanel control panel, this may be one of the options you are provided- if it is enabled, you can edit mime types )
The control panel is very limited. The .htaccess is nowhere to be found, I was told I could create it above the root I think, but I can't find any way to get above the root. I'll have to check on the SSI and see if the host supports it. Thanks for the tip.
Oh, the $99/month, what I meant was, it wasn't worth the $99/month to go to a dedicated host just to get a little php action in my html file.
Posted: Wed Dec 14, 2005 6:32 pm
by josh
You can get a VPS "virtual dedicated" for $20 a month, and you can get shared hosting for as low as $5 with PHP enabled.
Posted: Wed Dec 14, 2005 6:38 pm
by mikeycorn
You guys will probably laugh, but I'm learning lots here. Before this thread, I wouldn't really have been able to conceptualize what you get by going with a virtual dedicated host.
Posted: Wed Dec 14, 2005 7:19 pm
by RobertGonzalez
You gotta start somewhere. We all did (except maybe Feyd, who I think was born out of the embodiment of Pure Intelligence).
Posted: Wed Dec 14, 2005 7:41 pm
by mikeycorn
Posted: Wed Dec 14, 2005 7:44 pm
by trukfixer
Well using SSI, doesnt necessarily mean having to change to .shtml .. You could also use a URL rewrite , or perhaps even a 404 directive , all of which I have used at various times just experimenting with stuff, all getting the same desired end results
You can also drop in a .htaccess file in your document_root
(If your host tells you to put a .htaccess file in to modify how apache does things, it needs to be in yrou document_root, or below, they may have meant that- apache wont read a .htaccess file that is *above* DocumentRoot - so putting .htaccess there is useless)
I.E.
/var/www/username - this is your root folder on virtual (for example)
/var/www/username/public_html - This is your Document_Root (where your index.html file is)
/var/www/username/public_html/images - This images folder is "below" Document Root (the parent directory is "Above" it)
If you wanted to use a .htaccess directive in your case to AddHandler to make html files be parses as php, you would put a .htaccess file *in* the same directory as your index.html file , which is "DocumentRoot"
Putting .htaccess in a directory where Apache would never go to (Above your root) - would be a useless exercise

Posted: Wed Dec 14, 2005 8:05 pm
by mikeycorn
Okay, I made a file called htaccess (all my time in Windows, I never even knew you could make a file and completely remove the extension) I used the line from Jcart's post:
AddType application/x-httpd-php .php .phtml .php3 .php4 .php5 .html
I placed that file right under the root, I tried a line of php in an html file - no dice.
Does that sound like I took the right steps and that would work for some hosts but mine shut that down?
Posted: Wed Dec 14, 2005 8:13 pm
by trukfixer
where, exactly is teh file *in relation to* your index.html ? - See my post above - your .htaccess should be put in the same directory as your index.html
try that and see..
if that doesnt work, your host probably has the "AllowOverride" directive set to off... which means you are stuck with whatever they set in the Apache configuration