Forum Moderators: open

Message Too Old, No Replies

Server Side Includes without changing the file extensions?

         

RichardD

6:24 pm on Dec 30, 2005 (gmt 0)

10+ Year Member



I have a site with around 700 static pages. These pages are divided into categories like blue widgets, green widgets etc. Within a category, all the pages link to one another. So, on every page within a category there are anywhere from 50 to 130 internal links. The actual content on the page is relatively little relative to the html.

At one time Google liked this arrangement and the pages did very well in the SERPs. However, during one of the major Google updates (maybe Bourbon), these pages fell into the abyss. Today, a handful are in the top ten positions, but most are hundreds or thousands of positions down. There could be many reasons for this drop, so I have been researching and testing possible causes.

I tested the theory that the ratio of html to content was off balance. To test this theory, I reduced within a whole category of pages the number of internal links on any one page to around 10. This had no positive effect and possibly an adverse effect on Google results and a very adverse effect on MSN Search’s results.

My theory now is that if I re-include all the category-specific internal links, it wouldn’t hurt my positions in Google and would probably help my positions in MSN Search.

Now, what I propose to do is use CSS and server side includes to add the navigation links to my static pages. This way I can maintain a healthy html-to-content ratio and still possibly benefit from the internal links, at least on MSN Search. However, there seems to be a problem. If I have to change all my pages from .html to .php so I can use includes, I will have to start out at square one with Google and all other SEs and directories. Am I correct on this?

How can I solve this problem?

I read Ogletree’s suggestion ( [webmasterworld.com...] ) of including a command in a .htaccess file. But, I don’t really understand if this applies to my case and how I can implement it. I’m still wet behind the ears with regards to a lot of this work.

I’d appreciate any help I can get. Thanks.

Richard

[edited by: tedster at 6:45 pm (utc) on Dec. 30, 2005]
[edit reason] make the link live [/edit]

RonPK

7:28 pm on Dec 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ogletree suggested adding this line in .htaccess:
AddType application/x-httpd-php .html

It tells Apache to let all files with the extension be parsed by PHP. So it actually turns your HTML files into PHP files, enabling you to use PHP's inclusion features.

You may want to look into sending some extra headers to fool the if-modified-since part of the browser request.

tedster

8:01 pm on Dec 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This way I can maintain a healthy html-to-content ratio...

Includes will only affect that ratio in terms of what you see in your html editor. IF (and that is a big if) search engines watch that metric in any way, they are seeing the file with the include already in place.

RichardD

8:38 pm on Dec 30, 2005 (gmt 0)

10+ Year Member



Thanks, guys. Very helpful replies.

Now, if I put a .htaccess file into my root directory with "AddType application/x-httpd-php .html" in it, will it adversely affect .html files that have no php includes in them? In other words, will my regular .html files (sans php includes) parse as .html files and not .php files?

Tedster.

<<IF (and that is a big if) search engines watch that metric in any way, they are seeing the file with the include already in place.>>

By this, I understand that you strongly doubt that Google or any other SE pays any attention to the ratio between .html, such as links, and content. Is this a correct understanding?

Thanks.

Richard

tedster

12:23 am on Dec 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right. I strongly doubt that any engine looks directly at that ratio. Nevertheless, I do think that web authors should pay attention to it. WHAAA? I hear you say?

Keeping the ratio of content to total file size as high as possible is an excellent discipline -- that discipline helps us make choices that do have a positive impact on how well our site works, both for the engines and for our visitors. It also keeps us away from too many gizmos that are only a burden to the browser, and it also helps us minimize accidental coding errors.

But search engines care mostly about relevance, and there's nothing here about relevance -- although there may be a visitor satisfaction factor in a page that loads fast and doesn't send traffic directly to the Back Button and a different choice from the same SERP. That's an indirect but still very real influence.

encyclo

2:20 am on Dec 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



will my regular .html files (sans php includes) parse as .html files and not .php files?

If you go down the .htaccess route, then unless you can specifically target a particular subset of files which need to be parsed for PHP then all the files ending with .html will be parsed. If the file contains no PHP it will still display as a regular HTML file, however you will have the disadvantages of extra load on the server (albeit minor) as well as making the files non-cacheable by the browser. This latter effect will increase bandwidth use (as the file has to be fetched each time from the server rather than from the browser cache) and may have a slight visible effect of slowing down page access.

If only certain files need to be parsed for PHP then you should try to target them specifically, or consider the X-bit hack method and use SSI.

RonPK

2:58 pm on Dec 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to elaborate on the 'if-modified-since' I mentioned and encyclo's remarks on non-caching problems: you can send a custom 'Last modified'-header with the date/time the file was last modified in stead of the timestamp at request.

header("Last-Modified: " . gmdate("D, d M Y H:i:s ", getlastmod()) . "GMT");
header("Expires: Fri, 4 Apr 2064 05:00:00 GMT");

Include those lines at the start of your PHP-ed HTML files.

py9jmas

3:03 pm on Dec 31, 2005 (gmt 0)

10+ Year Member



header("Expires: Fri, 4 Apr 2064 05:00:00 GMT");

Arn't you telling web caches that this page isn't going to change, at all, until 2064? And that they can keep dishing out their cached copy until then, without having to check if it has changed at the origin server?

RonPK

3:42 pm on Dec 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're probably right, py9jmas. I guess it may be better to send an expiration header that says "please check again 1 day (or 1 week or...) in the future".

In PHP: header("Expires: " . gmdate("D, d M Y H:i:s ", getlastmod() + (60*60*24)) . "GMT");

An alternative is to not send the header at all. My impression is that most browsers ignore the expiration date and only look at the last-modified date.

RichardD

9:42 pm on Jan 1, 2006 (gmt 0)

10+ Year Member



Happy New Year everyone.

To experiment with allowing the browser to parse .html files as .php files, I uploaded a .htaccess file with the single line “AddType application/x-httpd-php .html” in it, to a folder on my site. In the same folder I have three other small test files named “css-test.html”, “css-test-include.html” and “css-test.php”.

I got disappointing results from my experiment. Here they are:

1. Css-test.php works fine and includes “css-test-include” as instructed with a “require” command.

2. Css-test.html, whose code is identical with css-test.php, doesn’t work at all, even with the .htaccess file that I described above, in the same folder.

But here’s where things really get bizarre.

When I FTP’d the .htaccess file to the said folder, the FTP program acted as if it had successfully transferred the file, but I could never see the file on the host site.

So, I tried something different. I uploaded the file to my root directory. That’s were things really got good (well, bad).

As a result of uploading the .htaccess file to the root directory, I couldn’t download my home page. My browser (IE) couldn’t tell what kind of file it was. Again, I couldn’t see the .htaccess file on my host site, so I couldn’t delete it.

The only thing I could do was to overwrite the .htaccess file with another completely empty one. Then my home page acted normally.

Any ideas on what I have been doing wrong and how I could fix the situation?

Thanks.

Richard

RonPK

10:28 pm on Jan 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some ideas bubble up:

* many FTP programs will not by default show files with names like .htaccess or .foo, i.e. filenames with nothing before the dot. Check your clients manual on how to list all files.

* you need to upload .htaccess-files in ASCII mode, not binary.

* the server administrator needs to have allowed users to use commands like AddType in their directories. Check with your administrator.

cws3di

10:51 pm on Jan 1, 2006 (gmt 0)

10+ Year Member




RonPK is right - most FTP tools have a way to "show hidden files", you might try to see if you have a right-mouse-button drop down menu? Or some sort of Options setting...

Definitely make sure you are uploading in ASCII not binary.

Also, some servers may require you to use BOTH the AddType and AddHandler lines in your .htaccess file, e.g.

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

.