Online Chat
 Call Us: 
1-877-744-1221
Browse Submit a Ticket
 
Advanced Search
Tools
Rss Categories

I get a page with source code junk instead of published content

Author: Edward Hardin Reference Number: AA-00377 Views: 13232 Last Updated: 10/15/2010 12:43 PM 0 Rating/ Voters

Q: I'm trying to test-publish a single article through Administration>Publishing>Publications. When I hit Preview, it looks all right, however, when I attempt to get the code and paste it where suggested I get a page with source code like this:

Source code when publish to html page

Any ideas?


A: When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn't have anything to process on the server. If server sees a .php extension, it knows that it needs to execute the appropriate code before passing it along to the browser. There are two solutions for this problem:

  1. Simply rename your .html or .htm page in order to set .php file name extension (e.g.: page.html -> page.php).
  2. Modify the .htaccess file (or create it if there is no .htaccess file yet) in the folder with publication and tell it to execute PHP code in .html pages by adding following line:
    AddType application/x-httpd-php .html
    If you're going to use one publication page only, it is better to do it this way:
    <Files page.html>
    AddType application/x-httpd-php .html
    </Files>
    Do not forget to replace "page.html" with your web page name.
Note
Second solution with .htaccess file editing is supported by Apache servers only since they work with .htaccess files and is not supported by IIS servers.