Home arrow Search Optimization arrow Page 3 - PHP Search Engine Optimization
SEARCH OPTIMIZATION

PHP Search Engine Optimization
By: Roger Stringer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 43
    2005-01-26

    Table of Contents:
  • PHP Search Engine Optimization
  • Session IDs
  • Mod_rewrite
  • ForceType

  • Rate this Article: Poor Best 
    SEARCH DEVARTICLES

    TOOLS YOU CAN USE

    advertisement

    PHP Search Engine Optimization - Mod_rewrite


    (Page 3 of 4 )



    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:

    http://example.com/index.php?act=articles&id=21&page=0

    That can turn into:

    mod_rewrite URL: http://example.com/articles/21/0.html

    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.

    More Search Optimization Articles
    More By Roger Stringer

    blog comments powered by Disqus

    SEARCH OPTIMIZATION ARTICLES

    - Feed Your Blog`s Readers Well
    - Laying Out An SEO and Traffic Generation Str...
    - Educational Viral Content
    - Viral Content Ideas that Appeal to Emotions
    - Tapping Popularity for Your Site`s Content
    - Mobile SEO Not So Different After All
    - List-Worthy Approaches to Viral Content for ...
    - Creating Different Types of Viral Content
    - How User Generated Content Helps SEO
    - Cyber Monday May Break Records
    - Should You Move Your Site to HTML5?
    - Schema.org and Microdata Markups for SEO
    - Search Optimization and 404 Errors
    - How to Compute Your Website`s Value
    - Get More Attention for Your Content
     
    SEO Chat Forums  
     RSS  Articles
     RSS  Forums
     RSS  All Feeds
    Contact Us 
    Site Map 
    Request Media Kit
    Write For Us Get Paid 
    SEO Weekly Newsletter
     
    SEO Tools
    Adsense Calculator
    AdSense Preview
    Advanced Meta-Tags
    Alexa Rank Tool
    Check Server Headers
    Class C Checker
    Code to Text Ratio
    CPM Calculator
    Domain Age Check
    Domain Typos
    Future PageRank
    Google Dance
    Google Keywords
    Google Search
    Google Suggest
    Google vs Yahoo
    Indexed Pages
    Keyword Cloud
    Keyword Density
    Keyword Difficulty
    Keyword Optimizer
    Keyword Position
    Keyword Typos
    Link Popularity
    Link Price Calculator
    Meta Analyzer
    Meta Tag Generator
    Multiple Link Popularity
    Page Comparison
    Page Size
    PageRank Lookup
    PageRank Search
    Robots.txt Generator
    ROI Calculator 
    S.E. Comparison 
    S.E. Keyword Position 
    Site Link Analyzer 
    Spider Simulator 
    URL Redirect Check 
    URL Rewriting 
    Privacy Policy 
    Support 


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
    Popular SEO Chat Topics
    All Tutorials & Tools
     
    SEO Chat is sponsored by:
    Close this Sponsor Message