Web Hosting Talk







View Full Version : PHP, PageRank and include...


grrlTechie
05-26-2005, 11:45 AM
This is not entirely a programming question, rather, coding and it's affect on PageRank.

I like to use 'include' to place content in my pages. I don't know if there is a *better* way or not, but what *I* like to do is create my index.php using tables and cells for where my content pages will go. This way, I have a 'banner.php', 'menu.php', and a 'footer.php' all placed appropriately in all of my pages. For the body of the page, I 'include' an assortment of php pages one at a time, that have no <html>, <title>, <meta> or <body> tags. In other words, I use my index.php as a template for the site and 'include' all other "pages" (read: files) are simple and have a very limited amount of HTML in them.

Therefore to call my "Contact Us" page, the menu will <a href> to index.php?page=contactUs.php. So, here's the question: Will using this kind of design be properly navigated by the SE bots? I have read all I can on the subject. Google says that as long as you keep the parameters short and few, it has no problem. However, I think they are talking about passing form variables... NOT the file name of the file that essentially makes up the page. Will they only index the index.php file since that is the only "real" page? If you need an explanation, see the site in question:
http://www.womenride.org/index.php
then http://www.womenride.org/menu.php (view the source)
or http://www.womenride.org/home.php
I think you'll understand what I'm doing. I like this method because I can change just about anything I want to and the change will be uniform across the entire site. (I'm learning to do more with CSS for some of this)
Thanks

grrlTechie
05-26-2005, 01:09 PM
I forgot a couple other issues....

1) With the above method, another concern is the use of <title>. HTML 4.0 rules say that the <title> *MUST* be in the <head>. Since my content pages are essentially text or html files that are included in the index.php page <body>, the only <title> would be the one in the index page... which has NO content until one of individual content files is included. So, what I've done is removed the <title> from the index.php and placed a <title> in each of my content pages. After going thru the PHP Processor, the served page is naturally placing the <title> in the <body>. No mystery there. Even though it's a against the rules, the latest versions of MSIE and Netscape both display the title in the title bar. Even though it works, should I refrain from this practice? Why?

2) Browser view. I'd be curious to know if anyone has any other browsers that are NOT displaying the page titles properly.

Thanks again.

Googled
05-26-2005, 03:48 PM
Hi grrlTechie,

the way you are working with files to get them together is a great way. You should'nt worry about how the SE bots will handle your code it doesn't really matther to them.

Except for THE one thing they can't handle.. javascript.. as long as all your urls are in a <a href>, <frame>, and so on.. tags they will find their way by themselves :)

Regards

WO-Jacob
05-26-2005, 03:59 PM
I would really use php's output buffering to move that <title> back into the <head> tag though. Better safe than sorry.

Oh, and mod rewrite.

RewriteEngine On

RewriteRule /pages/(.*) index.php?page=$1

then use http://www.yourdomain.com/pages/contactus.php or whatever. You have no variables then. It just looks nicer.

grrlTechie
05-26-2005, 05:16 PM
Originally posted by WebOnce
I would really use php's output buffering to move that <title> back into the <head> tag though. Better safe than sorry.

Oh, and mod rewrite.

RewriteEngine On

RewriteRule /pages/(.*) index.php?page=$1

then use http://www.yourdomain.com/pages/contactus.php or whatever. You have no variables then. It just looks nicer.

Wow! Those are fantastic! I'm self-taught at PHP. I've never encountered ob or the Rewrite Engine. So, that was a big big help.
I just played with the ob, offline. There's a little bug there in my code with JS not liking something I did, but it works! I'll tweak it and start rewriting some code to include the rewrite engine.

Thank you so much!

WO-Jacob
05-26-2005, 05:19 PM
Your very welcome :) we use mod_rewrite all over our site just to make nicer looking file names and such, also to simpify some complex things (like making pretty links to get to site builder, and making some very nice looking entry order url's.)

sasha
05-26-2005, 09:59 PM
I look at making a web site like playing with legos. You put many small blocks togather and then show it all at once when they all come togather. I posted a quick sample here:
http://tnt.goldnet.ca/basesite/
There is nothing pretty there but it should do fine to help me explain lego thing. There is one main page. In that page there are tokens that look like this %TOKEN%. Depending on your request those tokens get populated with all kinds of content and make a page. Each of those content blocks can be built from many other blocks containing more tokens or it can be just a siimple word. That allows me to have pages which are pure HTML separate from PHP side of things. That becomes very usefull when you have designer working on design, someone working on layout and HTML stuff, someone else putting and maintaing content and someone doing coding stuff.

Take a look at links and .htaccess as well to see how is that taken care of.

grrlTechie
05-30-2005, 04:35 AM
Originally posted by WebOnce
I would really use php's output buffering to move that <title> back into the <head> tag though. Better safe than sorry.

Oh, and mod rewrite.

RewriteEngine On

RewriteRule /pages/(.*) index.php?page=$1

then use http://www.yourdomain.com/pages/contactus.php or whatever. You have no variables then. It just looks nicer.

I was successful with the buffering, but the rewrite stuff has got me stumped. I've spent more than 10 hours searching the net, reading, and trying various things on my local and vps servers. The best I've been able to do is trigger the "match" by using :
RewriteRule (.*) index.php?page=contactUs.php
This does nothing to the URL in the address bar, but it does load the contactUs page everytime, no matter what URL you enter (as I would expect). However, one odd thing that may help, is that the images from my images subdirectory are not being loaded. Remove the .htaccess and they return. I know the RewriteRule isn't what I want to use, but I was using what I thought to be a test to see if my httpd.conf file was configured correctly. Since the match is working, I would assume the conf file is correct? BTW, I think the RewriteRule you wrote above should be....
RewriteRule page=$(.*) /page/$1
Or, is that all wrong?

Oh, also I'm running my rewriteLog at 9 and I found the first line to be interesting... using the (,*) by itself for the "match".... I get "strip per-dir prefix" of an unrelated file in a subdirectory (images). Any suggestions?

Thanks :)

Burhan
05-30-2005, 10:29 AM
No, the RewriteRule is a regular expression.


RewriteEngine On
RewriteRule ^/page/(.*?)$ index.php?page=$1


In the above rule the $1 get replaced with the first group match -- groups are what is in the ( ). So if you had a rule like

^/page/(.*?)/(.*?)$

For a URL like /page/1/2

Then $1 = 1 and $2 = 2 and you would use

RewriteRule ^/page/(.*?)/(.*?)$ index.php?page=$1&section=$2

Hopefully this makes it a bit clearer.

For your log file result -- I would suggest restricting your rewrite rule by using RewriteBase. More info, as always, is in the manual :)

WO-Jacob
05-30-2005, 11:33 AM
Originally posted by fyrestrtr


RewriteEngine On
RewriteRule ^/page/(.*?)$ index.php?page=$1


RewriteRule ^/page/(.*?)/(.*?)$ index.php?page=$1&section=$2


I think, after banging my head against the wall, it would be ^page and not ^/page

doh :D