cromagnon Posted October 6, 2007 Share Posted October 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/ Share on other sites More sharing options...
~n[EO]n~ Posted October 6, 2007 Share Posted October 6, 2007 I think using HTML comment will work (or not) .... Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363434 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363435 Share on other sites More sharing options...
cromagnon Posted October 6, 2007 Author Share Posted October 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363448 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 So what I am saying is this is not a ie/ff issue, but more of a .htaccess issue. This is a server configuration issue. you have to configure your server to parse and run the PHP. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363450 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363453 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363458 Share on other sites More sharing options...
cromagnon Posted October 6, 2007 Author Share Posted October 6, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363467 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363473 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 why is it not possible to just rename it? Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363475 Share on other sites More sharing options...
cromagnon Posted October 6, 2007 Author Share Posted October 6, 2007 I can't rename because some of the old html pages ranks in google. To rename them will destroy ranking. :'( Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363480 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 the page rank will just rebuild better since the page will now validate better. that or just make a .htaccess that makes it process it as php, but this isn't a .htaccess/apache help forum so find one. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363481 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363482 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363484 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363487 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363488 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363492 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363494 Share on other sites More sharing options...
cromagnon Posted October 6, 2007 Author Share Posted October 6, 2007 Hmm, this is getting a little tricky. Unfortunately its not just a single pages. Its dozens of pages. I really do not like redirects. Is it really necessary? Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363499 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363502 Share on other sites More sharing options...
MadTechie Posted October 6, 2007 Share Posted October 6, 2007 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) Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363505 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363507 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/72104-need-firefox-to-ignore-php-on-a-html-page-how/#findComment-363528 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.