Page 1 of 2

Using .html pages to run .php

Posted: Fri Dec 16, 2005 2:33 pm
by nikkib20
Hi guys,

I realize I must just be missing some simple thing to get this to work because from everything I've read it's not hard.
Ok I have http://gods-heros-myth.com/godpages/bellerophon.php all built with different php menus and such and it works great! However, I can not have all of my pages rename to .php and still expect to keep my search engine rankings.

So I've been told I still keep my extensions as .html and edit a .htaccess file to have the .html pages run the .php code. Well no matter what I do...this page does not run the php code http://gods-heros-myth.com/godpages/bellerophon.html You'll see at the bottom the footer isn't running.

I dragged the .htaccess file off of my server and edited to be this:
AddType application/x-httpd-php .php .htm .html

I saved it and uploaded it into the root, the directory of my menus, and the directory of my .html page. No luck...

There is a .nsconfig file in the root of my main directory as well, but I do not know what that does.

What am I doing wrong??

Thanks!!

Posted: Tue Dec 20, 2005 8:20 am
by nikkib20
Does no one know how to do this other than the couple of web pages out there that mention this? What are any of the things that could cause this to go wrong? I was thinking this would be an easy question for many of you in here....

Posted: Tue Dec 20, 2005 8:24 am
by JayBird
Perhaps you host does not allow you to change this via htaccess...i would contact them and ask them

Posted: Tue Dec 20, 2005 8:27 am
by josh
just as easy:

use mod rewrite to rewrite all urls from html to php, now .html and .php will work on all your files

Posted: Tue Dec 20, 2005 8:40 am
by Simon.T
<script language="php"> include("../menus/footer.php");</script>
this is the last line of the code i saw when i looked at the link you posted,

i`ve never had this style of coding work and not sure if that would work on anything other than an ms server? (i have no idea really!!!)

depending on your server config this wont work, instead try using

Code: Select all

<? include("../menus/footer.php"); ?>
or

Code: Select all

<?php include("../menus/footer.php"); ?>
if anyone else is looking at this can you tell me the rules when you can use this style
<script language="php"> include("../menus/footer.php");</script>
Simon

Posted: Tue Dec 20, 2005 9:07 am
by JayBird
Simon.T wrote:
<script language="php"> include("../menus/footer.php");</script>
this is the last line of the code i saw when i looked at the link you posted,

i`ve never had this style of coding work and not sure if that would work on anything other than an ms server? (i have no idea really!!!)

Simon
Not seen that before myself, but i have just tried in on my server (apache) and it worked no problem :?

Posted: Tue Dec 20, 2005 10:04 am
by hawleyjr
This may help

http://fundisom.com/phparadise/php/html ... HP_in_HTML
AddType application/x-httpd-php .html .htm

Posted: Tue Dec 20, 2005 10:13 am
by nikkib20
I'm able to drag .htaccess off of my server, change it and then upload it...no problems so I will try the above.

WIth regards to the coding, it's not standard php, honestly I used it as a cut and paste from another website I'm cleaning up as a quick test. It works just fine on .php strings, but the problem above is a pain.

I can not afford to rename my pages to .php and lose my rankings. I'll let you guys know, thanks a lot :)

Posted: Tue Dec 20, 2005 10:24 am
by nikkib20
Ok guys, how would this method work?

just as easy:

use mod rewrite to rewrite all urls from html to php, now .html and .php will work on all your files

Posted: Tue Dec 20, 2005 2:56 pm
by nikkib20
Ok I'm sol on .htaccess

NOTE: Due to our enhanced security policies, you will be unable to change the default handler for .html, .php, or .cgi files.


Anyone know how to do the mod method above?

Posted: Tue Dec 20, 2005 5:25 pm
by Chris Corbyn
nikkib20 wrote:Anyone know how to do the mod method above?
It's just basic POSIX regex. mod_rewrite support must be compiled into apache before you do anything else. phpinfo() would show if that's the case or not ;)

In a .htaccess you'd simply do (untested)

Code: Select all

RewriteEngine On
RewriteBase  /

RewriteRule   ^([a-zA-Z0-9_]+)\.html(.*)$     $1.php$2

Posted: Tue Dec 20, 2005 7:12 pm
by josh
I thought he said he didn't have htaccess access, either that or I misunderstood and he just cannot change the default handlers (I think this might be what he meant)

Code: Select all

RewriteEngine On
RewriteRule *\.html $1.php
put that in an htaccess file, and if you don't get a 500 error then you should be good to go, to test it make a hello_world.php and type yourdomain.com/hello_world.html. All it's doing is making the URL look like a html

d11 - you can't access the query string like that

Code: Select all

# Search script
RewriteCond	%{QUERY_STRING}		q=(.*)
RewriteRule	^search$		search.php?q=%1 [L]
I use something like that usually, it rewirtes "search?q=test" to "search.php?q=test"

Posted: Wed Dec 21, 2005 9:55 am
by nikkib20
ok I'm switching hosts, will let you know how it goes. THanks for the help!

Posted: Wed Dec 21, 2005 10:02 am
by vincenzobar
last i heard google doesn't like IP changes!

Posted: Wed Dec 21, 2005 11:11 am
by AGISB
All depending on your Apache compilation. If your .conf does alow you to overwrite with .htaccess you can do it with .htaccess. If not you need to change your .conf and restart apache.