Forum Moderators: phranque

Message Too Old, No Replies

AddHandler application/x-httpd-lsphp .htm .html

         

unclej

6:54 am on Dec 10, 2014 (gmt 0)

10+ Year Member



I am trying to install a php contact form on a website that uses .html extensions. I dont want to change the site's url structure for seo reasons so I cant change .html to .php

I have been doing some research and it looks like it is not possible to use php code in .html pages. unless I put the following in my htaccess:

AddHandler application/x-httpd-lsphp .htm .html

so let's say I put that code in my htaccess and the contact form works.

My question is SEO related, I am concerned site will lose some SEO value.

If I put that code in my htaccess, what differences can the search engines detect? will everything appear exactly like before as far as google is concerned? or they can detect this change?

not2easy

8:20 am on Dec 10, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



People use php all the time in html pages. My menus and footers are php includes for static html pages. It gives you only one menu to edit when a page is added or goes away. It has not caused me any issues related to SEO (or anything else).

I have very reliable php contact forms on my static html sites, they are no problem at all if installed properly. You don't want robots crawling the works so you can block the nice bots in robots.txt and use file permissions to limit them all. It is a personal choice whether you would want to try to index your contact form, but a simple no index, no follow keeps that easy enough. Google would only see the forms if they follow your links to the page and no-index means they read it and go away.

I am not using the exact same format as you have posted for the AddHandler part in my htaccess file, but nearly the same, I would go with what your host advises. There are hosts that even AddHandler won't work on. It depends on how your host has set things up.

wilderness

9:27 pm on Dec 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are hosts that even AddHandler won't work on.


FWIW, In order to get the contact form (the only PHP on the site) on one of my sites working, I had to use the following (only found it by playing around after a google):

AddHandler x-httpd-php .html

It's not the correct syntax (the correct syntax will not work on my host), however it works.

lucy24

9:41 pm on Dec 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why bother with any of this?

RewriteRule ^contact\.html /contact.php [L]


Works for me.

wilderness

11:04 pm on Dec 10, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



lucy,
Most forms run a POST upon completion.
Would a Rewrite allow that?

unclej

12:32 am on Dec 11, 2014 (gmt 0)

10+ Year Member



hey guys,
I appreciate all the help. I can't 301 .html to .php because every page has a contact form. If it was just one page, I would do it.
So obviously, google will see something new on the site, a contact form that wasn't there before. This is fine by me. A presence or absence of a contact form wont make a difference.
I am more concerned about the site's backend appearing different to google. I can't really explain what I am trying to ask. I guess the best way to ask the question is: "if I enable this code in my htaccess, the next time google visits the site, what difference will they see?" will anything, anything at all appear different?

wilderness

12:40 am on Dec 11, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Personally, I've the contact PHP in a CGI directory which is excluded in robots.txt.

Not sure why anybody would desire (or flaunt) such a thing to any major SE, which would provide rankings and links to same.

lucy24

12:48 am on Dec 11, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Most forms run a POST upon completion.
Would a Rewrite allow that?

When I said "works for me" I meant that literally: It's what I personally do. No issues. By default, a RewriteRule will work on anyy %{REQUEST_METHOD}. So you'd actually have to add material if you wanted it to not work with POST.

I don't personally know whether $_SERVER['PHP_SELF'] yields the filename or the URL (assuming they're different). If it's the former, you'd need an extra step to subtract ".php" and replace it with ".html". But I just say explicitly, "contact.html", since it's all the same page.

I can't 301 .html to .php

No, no, no, the point is: not 301 redirect. Keep the URL in .html and then silently rewrite to php.

But you don't have a separately coded form for each page, do you? There is absolutely no problem with including (via SSI) php content in an html page.

unclej

1:35 am on Dec 11, 2014 (gmt 0)

10+ Year Member



hey guys,

Please please answer my question directly. I am begging you.
I have this code
AddHandler application/x-httpd-lsphp .htm .html

I am not asking "is it good or bad to use this code"

I am asking "if I use this code in my htaccess and it works great, the next time google visit the website, what will appear different to them?" That's all I am asking. what differences (if any) will the google bot see?

not2easy

4:14 am on Dec 11, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you want to see what Googlebot would see, use Fetch as Google in GWT and you will see it as they see it.

Just a suggestion - if your only concern is regarding the SEO effect of putting a contact form on every page you might have gotten more helpful responses by asking in the Google SEO News and Discussion forum: [webmasterworld.com...] instead of the Apache forum. Over here we try to help on Apache related issues.

lucy24

9:19 am on Dec 11, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if I use this code in my htaccess and it works great, the next time google visit the website, what will appear different to them?

I'm missing something. How can an internal server directive possibly affect a search engine's perception of your site? (Always excluding, of course, directives that outright prevent a crawler from seeing some content at all.) If the server is appropriately configured they'll see exactly what you want them to see, no more and no less.

You need to approach it from the other end. First figure out what you want to do, which includes how your content will be seen by both humans and search engines. Then work out how to make your server carry out this intention.

phranque

8:17 pm on Dec 11, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I am asking "if I use this code in my htaccess and it works great, the next time google visit the website, what will appear different to them?"


if googlebot requested a .htm file containing php code, the php code would now be "handled" rather than passing through as raw text to the user agent.

that's assuming the php code in .htm files wasn't already being handled elsewhere and/or everything else is now configured properly...