2007-06-14

Secrets of indexation of dynamic pages in search engines

I think, nobody will argue, that advertising in search engines - one of the most effective and cheap ways of promotion of a site. Searchers (anyway, their overwhelming majority) are ready free of charge indexing your site and to show links to it to people who search for it. Thus you receive very qualitative traffic, involving on the site many interested visitors. All is good, but unexpectedly there is very serious problem: many searchers refuse to index dynamic pages of your site. The most pleasant for us that, what is it occurs not because they dynamic that is why, that the search robot so thinks. But we can force to think it differently.

Personally I was engaged in this problem, when have started to untwist the catalogue of the goods of the best web-shops webshops.ru. PHP + MySQL well affected catalogue development, but it is very bad, on desire of searchers to index my site. Google and Yahoo have at all refused to index more than one (main) page of my site index.php. From here the conclusion, expansion does not render any influence on indexation, instead of indexed. ONLY the pages containing "?", "and" and "=" in URL.
Here we have closely approached to article subject, we should change URL all pages and to result it in a normal kind.

I know 4 ways as it to make.

Most lamer,s way. We write:

ErrorDocument 404 script.php

In a file.htaccess where script.php - the file in which it is processed requested URL and is deduced the necessary page. The way is based that you can invent any URL on which you then can unequivocally display the necessary page, having processed it (URL) a script which will be called if the page to which you refer does not exist.

In httpd.conf or.htaccess we write a line

Options Multiviews

Now the server at inquiry URL of a kind /one/two/three will search for a file one with any expansion (for example one.php) which you beforehand place in . And already in one.php it is assorted an environment variable $REQUEST_URI and it is shown the necessary page.

In httpd.conf or.htaccess we write

ForceType application/x-httpd-php

To these we say to a server, that if there will be an inquiry /index/one/two he should consider, that index, it not a folder, and a file. Besides it also a PHP-script. Naturally you will need to create a file index (without expansion) in which you will assort all inquiries.

And at last the most powerful tool of substitution URL program module mod_rewrite. In httpd.conf or.htaccess we write

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteRule ^index / (. *) $/index.php / $1

It we start the module, we establish module action only on the current catalogue, we define root URL and we say to a server, that at inquiry of the user index / <какой_угодно_текст> the user will be redirected to/index.php / <¬á¬«®_Òú«ñ¡«_ÔѬßÔ address. Like practical benefit from such redirection is not present, but if we use points 3 and 4 simultaneously the interesting result can turn out. On the site (webshops.ru) I have made so:

RewriteEngine On
RewriteBase /
RewriteRule ^index / (. *) $/index.php / $1
ForceType application/x-httpd-php

I.e. has switched on the mechanism mod_rewrite, has defined root URL, has told to a server to change all inquiries index / on index.php / and has told, that such URL it is necessary to accept for a PHP-script, having executed index.php. Simply and with taste.

Now, for example, having written to a line of a browser http://testsite.com/index/testsite, you (it not suspecting) will be redirected on http://testsite.com/index.php/testsite, and this inquiry will be executed as http://testsite.com/index.php with that only a difference, that in a variable $REQUEST_URI it will appear "/index/testsite", that after safe processing by a script, will show you the list of web-shops with their descriptions.

Such URLы will have on taste to any search robot (and from the aesthetic point of view they look better). There was last stroke.


In the script text, to a conclusion to the screen something (!) we send in header two magic lines:

Header ("HTTP/1.0 200 OK");//the line is necessary only for item 1
Header ("Last-Modified:".gmdate ("D, M d Y H:i:s", filemtime ("index.php")). "GMT");//the line is useful in any case

The first line speaks to the robot, what is it usual page, and the second - registers updating date, being based on date of last change index.php (a file which you process all inquiries).

If at you pictures on page are not displayed, you can register absolute ways to each picture. But it is better to register instead in given out pages a line. It you will tell to a browser, that if the visitor has come in a virtual directory (namely so directories by which we have just learnt to do are called), it is necessary to count a way to a picture not from it (it is not present), and from http://youirsite.com/.

All! Now you are ready to submit search engines all pages of your site with its full complement. I wish good luck!

No comments: