Here is the ideas and usages for How can we create an SEO-based website in PHP

Step-by-Step Guide to Publishing a HTML5 Mobile Application on App Stores
February 19, 2018
Reasons On Which is the best e-commerce platform for building a website
February 20, 2018

Here is the ideas and usages for How can we create an SEO-based website in PHP

SEO flat banner set with analytics support digital marketing isolated vector illustration

PHP is a helpful dialect, utilized by numerous everywhere throughout the Web. Be that as it may, it makes them fall flat. By its inclination, it isn’t internet searcher amicable. Truth be told, it’s the correct inverse. Be that as it may, with some smart tweaking, we can make PHP a capable device in the journey for web crawler predominance.

Legitimate website streamlining can make PHP even resemble an alternate content. You could influence it to resemble a HTML document or a few HTML records, one for each article on your site.

Here are few advantages and ease usages for creating SEO websites in PHP.


Speed is a major factor for websites. If a search engine spider follows a link on your site and is forced to wait too long for the server to process the PHP code behind that page, it may ignore your page and move on.

Best Sellers

The biggest slowdowns in a PHP script are typically the database and loop code. Try to avoid making any SELECT * calls; instead, name all the columns you want to retrieve. Using SELECT * on a table that contains 10 fields when you only want to use one or two fields is a waste of valuable resources.

To optimize loops, try to use duplicated code instead of loops that don’t repeat very many times. Additionally, use as many static values, such as count($array) values, inside the loop as you can, generating their values before they loop once.

{mospagebreak title=Session IDs}

The first issue to deal with is PHP’s tendency to add session ID numbers to links.

This is caused by having the “enable-trans-sid” option turned on, and it creates links with an additional, long, nonsense-looking GET variable. In addition to making the links clunky, it gives spiders different URLs with the same content, which makes them less likely to treat the pages individually. They might not even index them at all.


Sort of monstrous right? Presently envision being a web index arachnid and seeing that long number change each time you take a gander at the page. Not a pretty picture.

A snappy method to settle this is to cripple the trans-id highlight, on the off chance that you approach, in php.ini by setting “session.use_trans_sid” to false. On the off chance that you don’t approach change php.ini, you can add this line to the .htaccess record in your root registry:

php_flag session.use_trans_sid off

This will make the Session IDs disappear from the URL.

Friendly URLs

A major goal in optimizing your PHP pages for search engines 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 URLs 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:




Most of the search engines will be able to follow this link, because it has three or fewer GET variables (a good rule of thumb is to keep the number of GET variables passed in the URL to less than three), but any more than three variables will cause you to 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:




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.

Next, we’ll cover two methods of making your dynamic URLs more friendly. The first is mod_rewrite:

{mospagebreak title=Mod_rewrite}

It’s very important that you plan how to rewrite you URLs, because you don’t want to go back and change the links over and over again. Once you have a good steady map of how to rewrite your links, you can go ahead and modify a test script to see if everything worked. If your links work properly then you’ll be able to move on and modify all existing links. Let’s take a look at this example below:


That can turn into:


mod_rewrite URL:


Doesn’t that look much friendlier?

Once you have planned your URL rewriting, you are ready to set up your .htaccess file, which maps out what to do with each URL. Here’s an example of what to put in your .htaccess file.


I’ll explain how this works below.


RewriteEngine On
RewriteRule ^(.*)/(.*)/(.*).html /index.php?act=$1&id=$2&page=$3


In the example above we have two lines. The first line RewriteEngine On starts the mod_rewrite engine.


The second line does all the work.


RewriteRule ^(.*)/(.*)/(.*).html /index.php?act=$1&id=$2&page=$3


Here you are starting a RewriteRule.


RewriteRule ^(.*)/(.*)/(.*).html /index.php?act=$1&id=$2&page=$3


This is the start of a regex that allows you to create wildcards for the URL that your friendly URL. This allows us to use whatever we want between the (.*) and compare them to the second part of this rewrite rule.


RewriteRule ^(.*)/(.*)/(.*).html /index.php?act=$1&id=$2&page=$3


This is the final part of the rewrite rule that tells us how to map the friendly URL in part two of the RewriteRule to the actual URL that our script was written for. mod_rewrite will translate part one to part 2 automatically.

This works by using regex. The first (.*) will be $1 and the second (.*) becomes $2 in the translation. You can do this as many times as you want for your URL.

Say for example we had this URL: articles/21/0.html.

We’ll be matching up /index.php?act=articles&id=31&page=0 by using mod_rewrite!

Believe it or not, that’s all that’s really to mod_rewriting!

You can really get carried away with this by adding category titles to some of your rewrite URLs to make them even more search engine friendly. All you have to do is create another regex and don’t use that variable in your translation.

{mospagebreak title=ForceType}

Another way to make dynamic URLs appear static is by using Apache’s Force Type method in combination with a PHP command to interpret URLs like: as referring to a page called “articles” which is executed as a PHP script. This can be accomplished by inserting a line like this into the .htaccess file in the root of your web documents directory:



ForceType application/x-httpd-php

Now create a file called “articles”:

$script = $_SERVER[“SCRIPT_NAME”];
$nav = ereg_replace(“^$script”, “”, $nav);
$nav = str_replace(“.html”, “”, $nav);
$vars = explode(“/”, $nav);
$article = $vars[1];
$page = $vars[2];

It works in a similar way as the mod_rewrite example does, but with a little more work.


One major favorable position to utilizing dynamic pages rather than static pages is the capacity to make content that is always showing signs of change and refreshed progressively. You can utilize the traps above, joined with RSS channels from different locales and other consequently “new” substance to help your positions in Google and numerous other web indexes.


Another preferred standpoint to utilizing PHP is that you can make straightforward changes to numerous contents to make significant page titles. Since this is the most vital factor in SEO, uncommon consideration ought to be given to making title labels that precisely mirror the page’s present substance.

Any HTML templates that are used in PHP pages can be altered to contain this line:




With this, $page_title can be set to a keyword rich text 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.


Leave a Reply