Page 1 of 1

Odd request - searching a static site

Posted: Tue Aug 23, 2005 4:35 am
by sleazyfrank
Howdy folks - to me this seems a no-brainer; it can't be done. My boss wants the majority of our new site to be static html so that google et al will rank the pages, but he also wants to make the site searchable. Now we could use the lame google search tool, which is free but contains ads and is google. Is it possible to use php and mysql in conjunction to allow the site to be searchable? We provide training courses so the pages have to be searchable.

I suppose one idea would be to make a db with a field for the page title, description, keywords, content and a link to the original html page and build some php code that searches against this table for inputted keywords and produces a list of matching content and links. The links will then go to the original html pages. Is this how the google engine works?

frank

Posted: Tue Aug 23, 2005 5:39 am
by anjanesh
If the reason why you want to have static (html) pages is because of google indexing it, then better use mod_rewrite in .htaccess - this way it'll look like static html pages to google.

Posted: Tue Aug 23, 2005 7:23 am
by sleazyfrank
anjanesh wrote:...use mod_rewrite in .htaccess - this way it'll look like static html pages to google.
Hi - could you explain this in more depth please - I am only new to php. Thanks

Frank

Posted: Tue Aug 23, 2005 8:58 am
by John Cartwright
Let me give you an example of how you can have dynamic pages that will trick google into thinking the pages are static.
Well lets say you have a news page which only holds the latest 4 news article, obviously a dynamic page and google will not index this very well. Well at the bottom of each of the articles you should provide a "permanant link" to the article.. so google can cache this and it will never change. Same applies to all other dynamic pages, provide a permanent link to all dynamic content so google can read through it.

Now lets move on to .htaccess. We all know that google doesn't like query strings very much, so the internet gods invented something called mod rewrite -- dwhich is basically rewritting the URL however we like it.. in this instance how GOOGLE likes it (html pages). Well your going to have to modify your site files files a bit to output the proper URLS, but something along the lines of

http://domain.com/news_14.html

in htaccess

Code: Select all

Rewrite Engine ON
Rewrite Base /

Rewrite Rule ^([a-zA-Z]+).html$ /?goto=$1 [L]
Rewrite Rule ^([a-zA-Z]+)_([0-9]+).html$ /?goto=$1&id=$2
Now let me explain that a bit.. this will match any link to /pagenamehere_idnamehere.html to ?goto=pagenamehere&id=idnamehere.
The page name has to be all letters and the id has to numerical or it won't match. You can also ignore the id and it will just match the page name. You also may have noticed the [L] and that is there to stop htaccess from going down the list of rules if it that particular one matches