index.html / index.php
Moderator: General Moderators
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?
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?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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.
On a shared host, this is usually the case, unfortunantly.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?
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.
.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.
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:
Still, I learned a lot from this thread so thanks a bunch to both of you for helping educate a server side newbie.
Actually, the switch was so quick as to be inperceptible to the user, so it wasn't a bad solution in the first place.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>
Still, I learned a lot from this thread so thanks a bunch to both of you for helping educate a server side newbie.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.
Just an FYI.
- trukfixer
- Forum Contributor
- Posts: 174
- Joined: Fri May 21, 2004 3:14 pm
- Location: Miami, Florida, USA
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 )
$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
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
I never really got why they put up that message. Now I know. Good tip, thanks.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.
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.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 )
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- trukfixer
- Forum Contributor
- Posts: 174
- Joined: Fri May 21, 2004 3:14 pm
- Location: Miami, Florida, USA
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
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
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:
Does that sound like I took the right steps and that would work for some hosts but mine shut that down?
I placed that file right under the root, I tried a line of php in an html file - no dice.AddType application/x-httpd-php .php .phtml .php3 .php4 .php5 .html
Does that sound like I took the right steps and that would work for some hosts but mine shut that down?
- trukfixer
- Forum Contributor
- Posts: 174
- Joined: Fri May 21, 2004 3:14 pm
- Location: Miami, Florida, USA
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
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