This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Integration in html page
#1

Is it possible to integrate the script in a html page? I cannot change my existing file extensions from html to php otherwise their rankings of the search engines will fall down to zero.
Reply
#2

Hi,

I'm afraid it needs to be a PHP file.

There are a couple of options that you may not have considered:

1. Changing the file extension to PHP and then using .htaccess to re-write the extension to HTML.

2. Changing the file extension to PHP and then using .htaccess to do a permanent redirect (301).

Have you completed the interview?
Reply
#3

Thanks for the answer. Can you tell me what exactly I must write in .htaccess for either rewrite the extension and the redirect? And what consequences both solutions will this have on the ranking?

I already tried the code

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

in .htaccess but it does not work. The guy who recommends this argues that with this code the server executes php code in html pages.

Reply
#4

A permanent redirect would look like this:
Code:
Redirect 301 /somepage.html http://www.example.com/somepage.php

Search engines will transfer the page ranking across. Just make sure to keep it in place for a while.

I haven't ever had to rewrite a file extension but found this:
Code:
AddHandler application/x-httpd-php .php .html .htm

Search engines won't even know anything is different.

Have you completed the interview?
Reply
#5

(10-Apr-2011, 02:09 PM)Huldrich Wrote:  Is it possible to integrate the script in a html page? I cannot change my existing file extensions from html to php otherwise their rankings of the search engines will fall down to zero.

Hi Huldrich.
try adding this line to your .htaccess file in the directory where the HTML pages are in which you want to include a PHP code:
Quote:AddType application/x-httpd-php .html
Next, all you need to do is put this piece of PHP code you want to include into a PHP file (open your favorite text editor and write your code, then save it as .php file.)
Next, include your PHP code at any place you want to appear it in your HTML file by calling it like this;
Code:
<?php require("pathtofile/myphpfile.php"); ?>
Note that you need to replace this part "pathtofile/myphpfile.php" with the actual path and name of your website!

Hope I make sense Cool (it works fine with me here and I have dozens of HTML pages with several of these includes each.

Best of luck

Reply
#6

Hi all,

My pages are pure html with some javascript. I implemented what Norbs said and it works well.

Thank Steven and Norbs
Reply
#7

hy all
i have a html page and i try put in but i get this error
Warning: require() [function.require]: URL file-access is disabled in the server configuration in /hermes/bosweb/web277/b2772/ipg.mysite/index.html on line 56

Warning: require(http://www.mysite.com/most.php) [function.require]: failed to open stream: no suitable wrapper could be found in /hermes/bosweb/web277/b2772/ipg.mysitecom/index.html on line 56

Fatal error: require() [function.require]: Failed opening required 'http://www.mysite.com/most.php' (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in /hermes/bosweb/web277/b2772/ipg.mysitecom/index.html on line 56

Reply
#8

(22-Sep-2011, 05:21 PM)jason4886 Wrote:  hy all
i have a html page and i try put in but i get this error
Warning: require() [function.require]: URL file-access is disabled in the server configuration in /hermes/bosweb/web277/b2772/ipg.mysite/index.html on line 56

Warning: require(http://www.mysite.com/most.php) [function.require]: failed to open stream: no suitable wrapper could be found in /hermes/bosweb/web277/b2772/ipg.mysitecom/index.html on line 56

Fatal error: require() [function.require]: Failed opening required 'http://www.mysite.com/most.php' (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in /hermes/bosweb/web277/b2772/ipg.mysitecom/index.html on line 56

Hello,

As far as i'm aware you can't use 'http://www.mysite.com/' or any full domain in required, required_once or include it needs to be path/to/folder/file.php - as far as i'm aware..

If you only plan on including the PHP on one page, it is better to setup this way:
Code:
<Files yourpage.html>
AddType application/x-httpd-php .html
</Files>
OR
<Files yourpage.html>
AddType application/x-httpd-php .htm
</Files>

for .html:
Code:
AddType application/x-httpd-php .html
for .htm
Code:
AddType application/x-httpd-php .htm


anything in your .html files that starts with <? will now be executed as PHP, so if it's in your file for some other reason (an XML tag for example) you will need to echo these lines to prevent errors. For example:
Code:
<?php echo '<?xml version="1.0" encoding="IUTF-8"?>'; ?>
Reply
#9

thank you jordann for your help
its work now evrything comment name email.thank you everybody.and the free script.
But now i have a little problem the comment what i sent and show above is grey so is very hard to read how can i change the letter color to black?
thank you again
Reply
#10

(23-Sep-2011, 05:38 PM)jason4886 Wrote:  thank you jordann for your help
its work now evrything comment name email.thank you everybody.and the free script.
But now i have a little problem the comment what i sent and show above is grey so is very hard to read how can i change the letter color to black?
thank you again

could you provide me with url or screenshot what letter you mean? but it can be done with css (if i think i know what you mean by letter)

http://www.w3schools.com/cssref/pr_text_color.asp
http://www.december.com/html/spec/color.html
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by paulkienitz
06-Dec-2024, 08:53 PM
Last Post by drwx
29-Jun-2023, 09:34 AM
Last Post by nsuomine
20-Jan-2023, 08:32 AM
Last Post by Steven
04-Jul-2020, 06:46 PM
Last Post by MattyP
13-Apr-2020, 08:33 PM
Last Post by Steven
23-Jan-2019, 02:07 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)