Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

Designing search engine friendly PHP pages

Discussion in 'Programming' started by I'm H, Oct 17, 2005.

  1. I'm H

    I'm H Member Webmaster

    PHP pages have a reputation of being more difficult (or at least different) to SEO than static HTML pages. Here's an overview of the major issues encountered when trying to make PHP scripts rank well. While this focuses on PHP much of it is still relevant to dynamic pages in general. PHP Speed While page size does affect load time, spiders run on servers connected to high bandwidth networks, so download time is less important than the latency of the PHP script's execution time. If a spider follows a link on a site and is forced to wait too long for the server to process the PHP code behind that page, it may label your page as unresponsive. The biggest delays in a PHP script typically are the database and loop code. Avoid making SELECT * calls, instead explicitly name all the columns you want to retrieve, and if you are using MySQL, test your queries using the EXPLAIN statement. To optimize loops consider using duplicated code instead of low iteration loops, also use as many static values, such as count($array) values inside the loop as you can, generating their values before the loop once. URL Cleanliness A major goal in getting search engines to treat your PHP created pages well, is to make them look and act like static pages. If you have a large site you can use Apache to fake static looking URLs, or, with a smaller site, you can simply keep your GET variables to a useful minimum. In either case, however, never allow a spider to see links with different URL's to the same content. If the URL is different, the page should be too. One of the major problems most webmasters have with getting their dynamic pages to index is URL cleanliness. Since many dynamic pages are created with GET variables, lots of pages have URLs that look like: Page.php?var=lkdjdfhv&var2=345&var3=kfjdks Most of the search engines will be able to follow this link, because it has 3 or under get variables (a good rule of thumb is to keep the number of GET variables passed in the URL to under 3), but any more than 3 variables and you will run into problems. Try using less GET variables, and make them more relevant, rather that useless id numbers use titles, and other keyword rich bits of text. This is an example of a better URL: Page.php?var=category&var2=topic If the page requires more variables you may want to consider combining the variables by delimiting them with a hyphen or another unused character, and then splitting the variable in the target page. Masking dymamic URLs However the mere presence of a question mark in the URL will introduce a delay in google's indexing of the page. This from Mike Grehan's Interview with Daniel Dulitz of Google: “So the mere presence of a question mark in the URL doesn't throw us for a loop at all. We will crawl those pages more slowly than we do with pages without question marks in the URL. Purely because they've identified themselves as being dynamic and we certainly don't want to bring anyone's site down because we're hitting the database too hard.” Small sites will not need to worry much about this delay as it means your server is hit every few minutes, not a few times a second, but for larger sites this can slow down your site's inclusion into the index. Making dynamic pages look static without mod_rewrite A way to mask bulky dynamic page URLs (and avoid the question mark delay) is Apache's ForceType in combination with a PHP command to interpret URLs like: www.example.com/books/computers.html as referring to a page called “books” which is executed as a PHP script (I usually make a link on the linux server from “books.php” to “book” to make editing the script easier). The function will return an array of the additional values, including the category “computers”. This can be accomplished by inserting a line like this into the .htaccess file in the root of your web documents directory: PHP's SEO'ing Advantages A great advantage to using dynamic pages as opposed to static pages is the ability to create content that is constantly changing and updated in real time. RSS headlines, randomly circulating content and other automatically “fresh” content can boost your ranks in Google, and many other engines. Another advantage to using PHP is that you can make simple modifications to many scripts to create relevant and fresh page titles. Since this is the most important on page factor in SEO special attention should be given to creating title tags that accurately reflect the page's current content. Any html templates or used in PHP pages can be altered to contain this line: With this, $page_title can be set to a keyword rich test describing the page. Title text is also important in improving the click-through from SERP's, so be sure that the title tags doesn't read like spam, but more like a human created title. Also Check out: Stargeek's Intro to SEO Dan Zarrella 2003 Stargeek Studios

Featured Resources (View All)

Share This Page