Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2009-05-11, 11:23 AM   #1
ponygirl
on vacation
 
ponygirl's Avatar
 
Join Date: Sep 2004
Posts: 2,095
Send a message via ICQ to ponygirl
htaccess AddType question

I want to add this to my htaccess:

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

to be able to use php includes without changing my page extensions. I already have this in there:

AddType text/html .shtml
AddHandler server-parsed .shtml .html

at the top, before all of my rewrite stuff.

so can I have both in there or is there something I can add to what's already there?

thanks for any help!
ponygirl is offline   Reply With Quote
Old 2009-05-11, 06:00 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
With Apache1, you cannot run a page with SSI and PHP parsing at the same time.

With Apache2, you can, but, it isn't recommended. Apache2 would be something like:

Code:
<FilesMatch "\.htm(l)?$">
    SetOutputFilter INCLUDES
</FilesMatch>
AddType application/x-httpd-php .htm .html
maybe..... not all servers will allow you to mix them.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2009-05-11, 06:43 PM   #3
ponygirl
on vacation
 
ponygirl's Avatar
 
Join Date: Sep 2004
Posts: 2,095
Send a message via ICQ to ponygirl
Quote:
Originally Posted by cd34 View Post
With Apache1, you cannot run a page with SSI and PHP parsing at the same time.

With Apache2, you can, but, it isn't recommended. Apache2 would be something like:

Code:
<FilesMatch "\.htm(l)?$">
    SetOutputFilter INCLUDES
</FilesMatch>
AddType application/x-httpd-php .htm .html
maybe..... not all servers will allow you to mix them.
well that simplifies things

as I want to use the php, I'll just take out the SSI altogether then.

thanks
ponygirl is offline   Reply With Quote
Old 2009-05-12, 07:10 PM   #4
nate
I can now put whatever you want in this space :)
 
nate's Avatar
 
Join Date: Mar 2009
Location: Merica!
Posts: 543
Quote:
Originally Posted by cd34 View Post
Code:
<FilesMatch "\.htm(l)?$">
    SetOutputFilter INCLUDES
</FilesMatch>
AddType application/x-httpd-php .htm .html
Ewwwwwww.

echo @stripslashes( @join( @file( "http://www.somedomain.com/cgi-bin/someperl.cgi" ),"" ));

As for running htm pages as php, maybe in one directory it would be OK, but not sitewide. You dont really want HTM being parsed as PHP if you can help it. It will cause a performance hit.
__________________
Its just a jump to the left.

Last edited by nate; 2009-05-12 at 07:15 PM..
nate is offline   Reply With Quote
Old 2009-05-12, 07:28 PM   #5
ponygirl
on vacation
 
ponygirl's Avatar
 
Join Date: Sep 2004
Posts: 2,095
Send a message via ICQ to ponygirl
Quote:
Originally Posted by cd34 View Post
Code:
<FilesMatch "\.htm(l)?$">
    SetOutputFilter INCLUDES
</FilesMatch>
AddType application/x-httpd-php .htm .html
Quote:
Originally Posted by nate View Post
echo @stripslashes( @join( @file( "http://www.somedomain.com/cgi-bin/someperl.cgi" ),"" ));
ok you two, get a room

well I'm not up on all this techy stuff lol. If you tell me how to do something I'll understand it, but I probably won't know why it works

I have one directory with about 125 or so pages that I'd be needing the php on. Any new pages in that directory I would just do as php I guess.

I was thinking about just switching them to php anyway if I can do a global redirect or something since they're all in the same directory? I really don't want to have to redirect 125 pages separately, it sounds a bit messy.

for now I'm going to parse 'em, if you guys have a good solution my ears are open
ponygirl is offline   Reply With Quote
Old 2009-05-12, 07:28 PM   #6
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Quote:
Originally Posted by nate View Post
echo @stripslashes( @join( @file( "http://www.somedomain.com/cgi-bin/someperl.cgi" ),"" ));
realizing of course that if maxclients is set to 512, and you have 257 surfers hitting a page that is calling that url from your local server, you're going to get a connection refused on the 257th surfer's request. Since php doesn't support keepalives, do that more than once on a page and you've got 1+ a connection for each of the file requests, reducing the number of surfers that you can serve on your site.

And that doesn't really solve the problem. If a file is being included, sure, that will work, though,

Code:
echo @file_get_contents('http://www.somedomain.com/cgi-bin/someperl.cgi');
is a bit friendlier, and, honors the timeout timer built into php. file, if I recall, does not honor the default_socket_timeout. Neither does include/include_once or require/require_once.

If it is a local file, you're better off doing:

Code:
echo @file_get_contents('/path/to/localfile.html');
But, how do you handle normal SSI?

Code:
        <!--#config timefmt="%A %B %d, %Y" -->
        Today is <!--#echo var="DATE_LOCAL" -->
Without converting that code to php, you would have to add the output filter for INCLUDES. SSI is used for more than including other files including adding the query string to urls, displaying the current date, etc.

In the end, SSI wasn't used, so, it's a moot point.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2009-05-12, 07:34 PM   #7
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Quote:
Originally Posted by ponygirl View Post
I have one directory with about 125 or so pages that I'd be needing the php on. Any new pages in that directory I would just do as php I guess.

I was thinking about just switching them to php anyway if I can do a global redirect or something since they're all in the same directory? I really don't want to have to redirect 125 pages separately, it sounds a bit messy.
personally, I would leave them as .htm or .html files and just parse them. No supported evidence behind it, but, a gut feeling that google prefers .html files over .php

If you wanted to redirect files, you could do it with mod_rewrite.

If you want to silently serve the .php as .html (and for some reason didn't want to parse .html)

Code:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [L]
If you wanted to 301 redirect the old content to the new page

Code:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [R=301,L]
Personally, I would just turn on php parsing for .html files in that directory and not worry about it.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2009-05-12, 07:50 PM   #8
ponygirl
on vacation
 
ponygirl's Avatar
 
Join Date: Sep 2004
Posts: 2,095
Send a message via ICQ to ponygirl
Quote:
Originally Posted by cd34 View Post
personally, I would leave them as .htm or .html files and just parse them. No supported evidence behind it, but, a gut feeling that google prefers .html files over .php

If you wanted to redirect files, you could do it with mod_rewrite.

If you want to silently serve the .php as .html (and for some reason didn't want to parse .html)

Code:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [L]
If you wanted to 301 redirect the old content to the new page

Code:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [R=301,L]
Personally, I would just turn on php parsing for .html files in that directory and not worry about it.
thank you |blowkiss| that's exactly what I want to do because it seems to be the easiest way.
ponygirl is offline   Reply With Quote
Old 2009-05-13, 09:15 AM   #9
LD
wtfwjd?
 
LD's Avatar
 
Join Date: May 2007
Posts: 2,103
Quote:
Originally Posted by cd34 View Post
personally, I would leave them as .htm or .html files and just parse them. No supported evidence behind it, but, a gut feeling that google prefers .html files over .php

If you wanted to redirect files, you could do it with mod_rewrite.

If you want to silently serve the .php as .html (and for some reason didn't want to parse .html)

Code:
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [L]
So if you wanted a "page.php" to display as "page.html" to perhaps take advantage of Google's hypothetical preference, this would work?

Interesting thread...wish I understood more of this stuff...
__________________
Artisteer Wordpress Theme Generator Create Custom Themes!
My Little Network
LD is offline   Reply With Quote
Old 2009-05-13, 10:38 AM   #10
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
IF google prefers .html over .php, yes, that would allow it. There are other factors to keep in mind -- moving existing, indexed content will surely cause an upheaval. Link trades pointed at those .php files will of course get redirects to the .html version which may lose some incoming link influence. You certainly wouldn't want to serve the same page as .php and .html or google may see it as duplicate content and toss one into supplemental (hopefully not the page you're trying to push). I wouldn't really recommend changing existing content, but, for new content I tend to prefer .html. I can see some of the reasoning behind it, but, that is just a tiny factor that I feel has a tiny influence on things.

php parsing itself has a detrimental side effect of setting the last-modified-time of the document to the current time. Technically that is true since the page was composed right then, but, that means that your documents never age and therefore might affect another metric that google looks at. Do you trust a page that is always updated more than a page that is a steady, archival version of an article?

Some of the history behind the different file extensions is a little odd. Ages ago, CPUs weren't as powerful, the php module built into apache wasn't a great performer. You had SSI which allowed you to put things like dates and do simple includes into documents - simplifying menus/navigation.

So, to preserve 'hardware', .html was for a document that needed no parsing, .shtml was used for documents with SSI. .php and .phtml was used for documents that needed php parsing. Because the default server config for .html usually didn't include php parsing, most developers just used .php because it was guaranteed to be parsed.

I could be completely wrong.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2009-06-05, 02:00 PM   #11
nate
I can now put whatever you want in this space :)
 
nate's Avatar
 
Join Date: Mar 2009
Location: Merica!
Posts: 543
If the html pages running as php are just getting a few hits, its no big deal unless you are running a really slow computer. On the other hand, if the html being parsed as php is a gallery listed on the hun, it will probably turn your server into jelly.

My guess is you will be alright, especially if CD34 says so.
__________________
Its just a jump to the left.
nate is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:53 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc