Jump to content

Recommended Posts

Hi PHP expters  :)

 

I have placed some php code in a template wich covers both php and html-pages. In Internet Explorer this works quite well, since Explorer just ignore the PHP scripts when Explore finds PHP on the html-pages. But in firefox its a problem, cause firefox simply prints out some of the php code on the html-page, so visitors can see the actual code.

 

I really need this to work, since all my templates covers both html and php pages.

 

How can I tell firefox to ignore the php code while reading a html page?!

 

Hope you can help  ???

 

 

Best

 

Cromagnon

 

 

 

The browser has no dictation on how the file is handled if proper headers and doc types are defined.  When a certain location is requested (the url) the server will respond to it, process it if need be and then send the output to the browser.  The browser has no dictation on how to handle a file beyond the interpretation of the given output.  So what I am saying is this is not a ie/ff issue, but more of a .htaccess issue.  If we could have a link to this, I might be able to help you, or if you post the code in here.

Thank you guys for very fast repons  :)

 

I tried the html comment method, but then the code was simply ignored on the PHP pages as well.

 

I will show you the problem:

 

On this PHP page you will see the working script in the upper right corner:

 

http://www.allthingschristmas.com/traditions/christmas-argentina.php

 

The following page is covered by the same template, but its an html page:

 

http://www.allthingschristmas.com/traditions.html

 

In firefox you will see some of the php code i the upper right corner.

 

Can I solve the problem? For many reasons its unfortunately not an option for me just to rename the html-page to php.

 

Thanks!

 

cromagnon

 

 

 

are you talking about

"; ?>

Latest forum posts:"; ?>

 

on the html page?  that is because some browsers will "try" and render some php if it can.  such as an echo statement with a quoted string and ignore the rest as commented out text.  The point is if you want it to render as php then make it a .php extension or set up apache to read .html extensions as a php file.

can you post that section of code

you probably have something like

<table width="92%" border="0" align="center" cellpadding="0">

                              <tr>
                                <td><?php echo "<?php echo "blar "<hr />"; ?> </td>

or

 

<?php 
echo '<table width="92%" border="0" align="center" cellpadding="0">

                              <tr>
                                <td><?php "<hr />"; ?> </td>';

This is my code. As said its unfortunately not possible for me just to rename the pages to .php

 

 

 

<table width="92%" border="0" align="center" cellpadding="0">
                              <tr>
                                <td><?php echo "<hr />"; ?> </td>
                              </tr>
                              <tr>
                                <td> <?php echo "<h4>Latest forum posts:</h4>"; ?> </td>
                              </tr>
                              <tr>
                                <td> <?php
			include("http://www.allthingschristmas.com/forum/lastposts3.php");
			?> 
                                </td>
                              </tr>
                              <tr>
                                <td><hr /></td>
                              </tr>
                              <tr>
                                <td><h4>Bookmark site </h4></td>

 

if you want to keep the file name .html and run PHP in it, your options are:

 

1. Modify .htaccess (or httpd.conf) to parse and run .html files as PHP

2. Modify .htaccess (or httpd.conf), adding an Apache rewrite to run a .php file but send the results to the .html address, sort of like this:

 

RewriteEngine On
RewriteRule ^somefile.html$ /somefile.php [L,NC]

 

so when someone navigates to somefile.html, the file somefile.php is run and it's results sent to the browser. the url remains somefile.html.

 

 

that is a bit of over kill as you can just get it to read the extension and process it based as if it was somethign else.  Its in the php.ini not .htacess I think.  As in the php.ini you can distinguish the php extensions cause I know some sites use the .phtml for php

if you want Apache to process all .html files as PHP, put this in .htaccess:

 

AddType application/x-httpd-php .html

 

but speaking of overkill, we just told Apache to process ALL HTML files as PHP. If the problem is only one file, just rewrite one url.

google can tell rewrites and don't like them vs a auto processing where if nothing is in it to precesses it loads very quickly.

 

wrong. no one, not even spiders can tell a rewrite. you may be thinking redirect. FYI: I am an SEO expert.

 

auto processing where if nothing is in it to precesses it loads very quickly.

 

and this is slower because Apache has to check EVERY SINGLE HTML FILE instead of just running one PHP file.

google can tell rewrites and don't like them vs a auto processing where if nothing is in it to precesses it loads very quickly.

 

wrong. no one, not even spiders can tell a rewrite. you may be thinking redirect. FYI: I am an SEO expert.

Assuming the rewrite doesn't cause an error, that true (clients are unaware as its server based)

 

Sorry my silly 2pence lol

NOT redirects. rewrites.

 

if you want PHP parsed and run in .html files, your options are as previously listed. if there are many HTML files like this, you'll want take cooldude832's advice and have Apache run all HTML files as PHP. that's just a one-liner in .htaccess or httpd.conf:

 

AddType application/x-httpd-php .html

 

That line in .htaccess will cause Apache to parse your PHP inside the HTML files without renaming any files.

 

by the way, here is an okay article on using rewrites for SEO-friendly URLs on various platforms:

 

http://www.avangate.com/articles/url-rewriting_70.htm

depends how much free time do you have ?

whats the fear (for lack of a better word) of the rewrite,

 

don't think of it as a page you site and wait for 5 seconds, and then get passed to a new page, its not a redirect (kinda)

yeah, a rewrite is like telling Apache: Whenever someone asks for somepage.html, parse somepage.php and send them the results. it's completely transparent to the browser/spider. here is an example:

 

http://www.1stradardetectors.com. click on ANY link. NONE of them are actual files, they are ALL Apache rewrites to SEO-friendly URLs.

I see no issue processing 100% of pages as php.  The load difference is almost non exsitance and it opens up the option of php on every page, which isn't that uncommon, without a major redesign.  However I tend to initially design my site so I can update navigation and so forth quickly using php includes so I guess I have a bias toward that

 

Fyi: I didn't know your a seo major, and secondly if it is a url rewrite that the browser can tell based on what it called for and what it is displaying then yes it will know, however that is never done.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.