Renaming *.html to *.php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Renaming *.html to *.php

Post by Vegan »

Would Apache as default be able to notice:

<script language='php' type="text/???"> echo '<p>Can U see me?</p>'; </script>

This would simplify installing widgets generally. I am borrowing from the JavaScript idea.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Renaming *.html to *.php

Post by Vegan »

scottayy wrote:There's a bunch of crap in this topic, LOL. Well not necessarily crap, but just beating around the bush.

Just rename your .html extensions to .php extensions and you can put php code in any of them. :) Simple. :) Don't worry about the .htaccess part, or search engine ranking.

I've had fairly busy web sites (upwards of 200,000 page loads per day) on a pretty normal server and server load never became a problem. I've also had .php pages rank well (and yes, in google).

Keep it simple. :D
Thanks for the clarification. I have since added JSP to the mess to see if I can figure out that as well.

The way I see it now, old documents are HTML, new active ones will be PHP or JSP as needed. Only recently been working more with Linux and active content. Seems to be a lot to learn.

I prefer the simplest solutions as they tend to be adequate. My sites are nowhere near that busy but some day? I wish.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Renaming *.html to *.php

Post by McInfo »

There is a way to get around the problem of broken links caused by making structural changes to your website (like changing all .html extensions to .php or moving files to different folders). In your 404 page (ex: missing.php), create a script that analyzes the incoming REQUEST_URI and tries to match it with an existing file. If a match is found, redirect to the matched page.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Mon Jun 14, 2010 11:15 am, edited 1 time in total.
coalgames
Forum Newbie
Posts: 8
Joined: Sun Apr 26, 2009 12:22 am

Re: Renaming *.html to *.php

Post by coalgames »

This is a little confusing to follow.

But a quick solution is to just go like this:

Code: Select all

 
<?php
$randomly_generated_number = rand(1,3);
switch ($randomly_generated_number) {
case 1:?>
<some><html></here>
<?php
break;
case 2:?>
<some><other><html></here>
<?php
break;
case 3:?>
<some><another><html></here>
<?php
}
?>
 
Kinda messy but can get the job done.

Then, if you are using a shared host, the php will be parsed inside html if there are <?php and ?> tags.
Post Reply