Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-04-2012, 11:17 PM   PM User | #1
oftheire
New Coder

 
Join Date: Feb 2012
Posts: 11
Thanks: 3
Thanked 0 Times in 0 Posts
oftheire is an unknown quantity at this point
Redirecting all links to .html files to .php?

Hello,
Recently moved site from godaddy to hostgator and their techsupport said that my #include files would not work on .html files and I would need to have only php files.

Is there a .htaccess fix for this or some way to do it that wont break all of the wordpress links from the blog?
oftheire is offline   Reply With Quote
Old 12-04-2012, 11:41 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Yes... there's an .htaccess command for this. Or rather a number of .htaccess options. Here's a tutorial:

http://www.velvetblues.com/web-devel...-files-as-php/
__________________
Fumigator is offline   Reply With Quote
Old 12-05-2012, 02:30 AM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,449 Times in 2,418 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Hostgator is silly.
#include is a part of virtual command, so that's an SSI, not PHP (ie: <!--#include virtual="/directory/included.html" -->). Those should be preprocessed as .shtml, not as .php. Now if that is just an include with include '/file'; /* or */ include('file');, then that would be PHP yes.
Fou-Lu is offline   Reply With Quote
Old 12-05-2012, 02:36 AM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
I completely missed that he was talking about Server Side Includes! Good catch.
__________________
Fumigator is offline   Reply With Quote
Old 12-05-2012, 07:04 AM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,449 Times in 2,418 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all

We must be getting old to know about the old ssi days!
Fou-Lu is offline   Reply With Quote
Old 12-05-2012, 04:35 PM   PM User | #6
oftheire
New Coder

 
Join Date: Feb 2012
Posts: 11
Thanks: 3
Thanked 0 Times in 0 Posts
oftheire is an unknown quantity at this point
Thanks all. But no this isnt for server side includes just regular ones.. you can see the site here. bestaccident-attorneys.com. The main page and case-evaluations page are php and work fine but everything else wont load any of the includes
oftheire is offline   Reply With Quote
Old 12-05-2012, 05:54 PM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,449 Times in 2,418 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
No, but that doesn't mean that SSI's are not in use. Server side includes are completely independant of the PHP code in use. You can technically (albeit, not at all useful) use PHP to generate output to represent as a .shtml code and pass that back to the server to deal with the SSI's. Typically we don't, as that is slow and kinda pointless; on apache webservers if you *really* wanted to use the SSI directives you can invoke the virtual() function to carry them out. All I was getting at is that #include isn't a PHP directive. If that's in a php file such as:
PHP Code:
<?php
#include 'afile';
Than it will be ignored as # is a commenting character in PHP (along with //, block with /* */ and doccomment with /** */).


So the best way is to check your HTML source code. If you literally see in it the #include in an SSI directive, than this would require a removal of the SSI and placement where desired within the php code. The logic is near identical (I'll even specify it as a PHP block for both):
Code:
print 'Some PHP code';
print '<!--#include virtual="/directory/included.html" -->';
print 'Some more PHP code';
And assuming the SSI is outputable, you can simply replace it as such:
Code:
print 'Some PHP code';
include "/directory/included.html";
print 'Some more PHP code';
If your host states that .html isn't include-able, that's complete rubbish. Think of it as a structural change; you literally take what is read from the call of the include, and place it within your PHP script. The logic would be: include -> close PHP tags -> import content -> open PHP tags, so if your include script is .HTML without any preprocess directives, then its output type would be text so it would insert that into the output buffer at that location. If its in PHP blocks than it would parse that first.

Unless you mean that you cannot parse .html as .php code (as in you are accessing a .html that should be interpreted as .php), then Fumigator had it correct in the first answer for modifying the handles to accept .html as a php executable type.
Fou-Lu is offline   Reply With Quote
Old 12-05-2012, 06:08 PM   PM User | #8
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,452
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by oftheire View Post
Thanks all. But no this isnt for server side includes just regular ones.. you can see the site here. bestaccident-attorneys.com. The main page and case-evaluations page are php and work fine but everything else wont load any of the includes
Server Side Includes are the regular ones for HTML as they work with a .shtml file extension or whatever other extension you map them to. PHP also has includes but they are only just on of hundreds of commands available there - they work with a .php extension or whatever other extensions you configure them to work with.

If you are using PHP included then all your pages are PHP.

To have .html externsions treated as PHP you'd just need the following in your .htaccess

Code:
AddType application/x-httpd-php5 .html
AddHandler application/x-httpd-php5 .html
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Tags
.htaccess, html to php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:45 AM.


Advertisement
Log in to turn off these ads.