PHP code and html are not rendering in webpages - html

Recently i can't render pages in php and html. it is all junk codes like this
![screenshot taken when page loads][1]
Is there any setting in php to render actual content?
BELOW is the content i see when i access pages in browser.
"
��\�s۶����+P�S%sm������$��7n}j�����p( �S$ˇm����~�_�D:��6��I,>,v��G߼����׋Wb-q����7g�v�l��{�l��z)���W�oE���Q[Q������^mE��f����q�mx��y�K���iS9�xr��4��N���������*h��cU�&�vp\s��&ӝפ��{GiN�w�(�#G�\z�m:�'�z����ř�\Ʈ�ġ��ne ���J���ww�T������L��Ky\3�h��)�s#�F�5E^Mn�)�����ؾ9��)�ë�/s�"y5��υ�0�PF���^� ���� O�\�P��M����T�V��������R ۝y�Ҥ,aN�8+/DhG��hl�+�&^�g�v����9�w[��w�^�sy�31������i-�!AxN�k�;䬭��o2��a{+����YR�c��"��q-�XG��TMD����yw��������Ĝ�a���͙yC$ �$��!���|0oL�JB��wc�;�)�şu ;4���v-��L�L'�B��ҢA4��4v$r9��l?�f��e�P�~�U�x���&�y�ҥ���x0��Ӯ9�ڽN�?������ ".

I'm guessing it's an Apache (or whatever webserver you're using) configuration problem. It looks like php files are being processed by something other than PHP. Check your MIME type handler for .php files in httpd.conf.

Related

HTML SSI's don't work in browser

I'm trying to use server side includes for both my header and navigation, as they will be constant across every page, and I'd like the ability to make frequent changes in one place and have them populate across all pages. I have tried a "file" and "virtual" include, and have tired placing the include files in the same directory. The include files have no duplicate code (doctype indicator, html tag, etc). I've also tried both .html and .shtml file extensions. I use the file explorer in DW to select the files, so I'm assuming the path is correct.
The SSI's preview fine in Dreamweaver, but will not populate in the browser. Any suggestions would be greatly appreciated.
<!--#include virtual="/lpapp/includes/influencer_header.shtml" -->
<!--#include virtual="/lpapp/includes/influencer_sidebar.shtml" -->
Dreamweaver probably support SSI. If you run your html from a random folder on your local PC, SSI won't work. As soon as you upload the project to a Apache webserver or a virtual server like Wamp/Mamp. It is possible to get SSI working using the right SSI syntax and .htaccess.

Sitecore and HTML files

We have a bunch of files (css, js, html, flash, swf, etc) put together by a third party to show videos on our site. This link is an example of the type of rendered output that i'm talking about - http://www.esi-intl.com/public/us/resources/virtualclassroom/presentation.htm. This isn't my company but I was able to find this via google since our site is not live yet.
Our editors would like to include these files in the Media Library and display these pages from there. I've tried to include these files but the HTML page doesn't render instead it is offered as a download. I've tried commenting out the Mime type in the Mimetype config file but I'm not having any luck.
Can the Sitecore media handler be modified to get these HTML files to render as pages?
Thanks
Html in media libary could.
To get the correct mime-type look at the setting name="Media.RequestExtension" set the value to "" then you get the original extension.
That makes things become easier for the web server to give the correct mime type.

Default HTML Page?

Alright, I don't know how exactly I'm going to phrase this, so bear with me here. Is there a way to set a default HTML page? Like is there a line of code that I can use on new html files to load a local .html file for almost a template?
Use any sever-side programming language to include header and footer parts of your default webpage.
Example on PHP:
<?php
echo file_get_contents("header.html")
?>
Your page contents
<?php
echo file_get_contents("footer.html")
?>
You can set default html page in your webserver. But that's just if someone hits http://server/ with no page name it tells what page to use like http://server/index.html versus http://server/default.apx, etc. Has nothing to do with templates.
If you want to be able to include html files inside other html files, you probably need a serverside language like ASP, PHP, JSP. HTML itself doesn't have that capability, although some webservers might offer a custom tag that is translated on server-side for includes.
The default web page on a server must have the name index.html, index.htm or sometimes default.htm. It is possible to change the server to accept other file names as default files, but those are the most commonly used ones. What is the index.html page?
If you're asking how to make your web browser open a default page when you open it, this is usually called the "Home Page" and any file or page that you can visit in your browser you can assign as the home page.
If you're trying to create a template for a web page, there are many ways to do it. The PHP example listed above is one way. You can also do it with JavaScript. Write your HTML in document.write() calls inside a file named navigation.js and then place this script where you want that code displayed:
<script type="text/javascript" src="navigation.js"> </script>
However, this is not unobtrusive and could cause problems. Another way to do it is with Server Side Includes. Write a file named navigation.ssi and then add the following SSI line to your HTML where you want the included file to display:
<!--#include virtual="/ssi/navigation.ssi" -->
You can also do it with ASP and other methods. I explain in more detail in my article How Do I Include One HTML File in Another?

Server side include no longer seems to be working - "[an error occurred while processing this directive]"

We have a page that has been using a server side include for many years. Recently it stopped working. No changes have been made to the page
<!--#include virtual="..\..\includes\nav.include" -->
Near the bottom of a page called contact.html
The 'nav.include' page simply contains html for a navigation bar. No javascript. No server side scripting. Just html.
Is there some setting somewhere that needs to be set to make SSIs work in the way it is implemented here (including a file with an uncommon extension inside a html file)?
A solution that I discovered yesterday:
I duplicated and renamed all my pages to .php (retained the original html files just in case!)
I have replaced all the {<#include virtual="folder_name/file_name.ext" -->} with
<?php include "folder_name/file_name.ext" ; ?>
with the appropriate number of dots and slashes depending upon where the pages are in my folder hierarchy. ( The {} above is to mark out the code only)
Finally, I renamed the original index.html to some other name so that the index.php is picked up instead of the index.html
This seems to be working out - I am still testing out all the pages and links - a very tedious and time consuming exercise!
INCLUDES SYNTAX:
In a php file use
<?php include "..//folder_name/file_name.ext" ; ?>
In an html file use
<!--#include virtual="../folder_name/file_name.ext" -->
EXPERIMENT WITH NUMBER OF "..." AND NUMBER OF "///" IN THE ABOVE SYNTAX TO GET THE CORRECT COMBINATION!!!!
For me, all my includes are small html files in a folder ABC which is directly under the webroot.
For pages which are under sibling folders of ABC i.e. in other folders directly under webroot, "..//" is the number of dots and slashes that work.
For pages which are directly in the webroot (i.e. not in any folder inside webroot), folder_name/file_name.ext without any dots or slashes has worked.
I haven't had the time to check out the number of dots and dashes required for any other level in the hierarchy!
I hope this helps!
Are you using GoDaddy? They did the same to my site, and I found on their forums someone that said to use include file instead of include virtual.
Just switched over to Godaddy servers and my SSI stopped working. I made a .txt file with the following:
AddHandler server-parsed .html
I uploaded it to the public html folder, then renamed it .htaccess, and everything started working.
I had too many files to convert all the extensions to PHP, so I had to find another answer, if at all possible.
For me, for a little while, exchanging include virtual to include file seemed to help, but then it broke again after a few days. I guess GoDaddy was not finishing monkeying around with the SSI configuration. o_O
The solution, as of tonight, was to convert all relative paths to absolute specification in regards to the site root. For example, I had to convert:
<!--#include virtual="..\..\includes\nav.html" -->
To:
<!--#include virtual="\includes\nav.html" -->
Using this approach, I was able to include HTML files inside other HTML files.
I discovered this on one of my pages that mixed absolute and relative path specification.
HTH
I've been seeing this problem frequently on my GoDaddy hosted site. I have to go into the Server configuration page, disable SSI, save the settings, then re-enable SSI and check "Use SSI on .HTM and .HTML files) and it starts working again.
The problem is on GoDaddy's side. For some reason, it's forgetting that it needs to parse SSI in files, until you turn off and turn on that option. Their Tier-2 support only suggested using Virtual instead of File on the Include command... which is preposterous, since not only does that not change a thing, the SSI includes work just fine most of the time... until it doesn't.
I'm also updating old .html pages to .php and replacing some of the with php include statements on all pages when some of the pages displayed [an error occurred while processing this directive].
The pages displaying the error also referenced an old .ssi file that wasn't even in the directory it pointed to. I deleted the old includes code to the non-existent .ssi file in those pages, and that fixed the error.
This error occurs when you have in your code html documentation like this
<!--#My awesome documentatacion-->
to fix it remove the #, like this
<!-- My awesome documentatacion-->

Application to including, extending html document without server www

I'm front-end developer and in work I use Twig with Symfony2 on Apache server. But now I have to make mockups in HTML, CSS on my interaction computer-human course on university. I need some application to able to including other html file in html file, extending html file with other html file - something similar like in Twig include and extend features. Does something like that exist?
I'd rather don't use html frame.
You could use server side includes - but this requires a server (hence the name !!)
Then you could, for example add a header to each page:
<!--#include virtual="header.html" -->
Apache, nginx, lighttpd and IIS are the four major web servers that support this language.
Your other option would be to use JavaScript and AJAX to pull in other content post load.