Welcome to Free VIN Check, Vehicle History Report, Used Car History, DMV, Vin Number Check, Vehicle Identification Number        
Zongoo.com Daily News - ( Advertise Here )


Free VIN Check

Used Car History Report

Used Car History

FREE VIN Check

Check Vehicle History Report using Car VIN Number

FREE VIN Check


Menu
· Free content
· Downloads
· FAQ
· Sitemap
· Top stories

Topics

· Arts
· Auto
· Business
· Business life
· Careers
· Computers
· eCommerce
· Electronics
· Emotional Intelligence
· Entertainment
· Finances
· Health
· Family life
· Investing
· Identity Theft
· Life Transitions
· Mental health
· Music reviews
· News
· Publishing
· Recreation
· Science
· Self development
· Society
· Sports
· Zongoo!

Content
· Abuse · Acne · Actor · Actress · ADD · Advertising Tool · Affiliate marketing · Affirmations · Allergy · Anger management · Apache · Apparel · Aromatherapy · Art · ASP · Astronomy/Space · Aviation · Bankruptcy · Barter and Trade · Bicycling · Books · Business · Cancer · Caregiving · Cars · Cell phones · Christianity · Cold Fusion · Commentary · Cooking · Credit Cards · Crime · CSS · Debt · Depression · Diabetes · Diving · Dogs · Domain names · E-mail marketing · Ebooks · Education · Electronics · Entertainment · Entrepreneurship · Featured authors · Feng shui · Fishing · Fitness · Foreclosure · Freebies · Games · Gardening · General · Gifts · Goals · Health · Holidays · Home · Home improvement · Homeland Defense · Hosting · HTML · Humor · Hypnosis · Identity Theft · Injustice · Inspiration · Insurance · Investing · Ireland · Javascript · Job · Landscaping · Leadership · Lifestyle · Link exchange · Loan · Magazines · Marketing · Marriage · Martial arts · Medical · Military · Money saving · Mortgage · Motivation · Movies · Music · Music marketing · Mutual funds · MySQL · Network marketing · Nonprofit · Opportunities · Paranormal · Parenting · Perl/CGI · Pets · PHP · Politics · Presentations · Prizes · Psychoactives · Public relations · Racing · Real estate · Relationships · Religion · Retirement · Sales · Search engines · Singer · Skin care · Sleep · Social · Space · Spam · Spirituality · Sports · SSI · Starting business · Stress · Success · Taxes · Technology · Terrorism · Travel · United Nations · Website design · Website marketing · Weight loss · Wildlife · Work at home · Writer resource · Yoga

Pre-Paid Legal Services
You have many rights as an American citizen today. Pre-Paid Legal Services can show you how to protect your legal rights at low cost. With Pre-Paid Legal, you can prepay your most common legal needs, much like you prepay your medical needs. It is important to know and exercise your legal rights as an American citizen. Buy from Pre-Paid Legal Services Independent Associate site:

Pre-Paid Legal Services

  • PrePaid Legal

  •  
    Computers: Computer, Software, Hardware:: Apache: Module mod_rewrite Tutorial (Part 3)
    Posted on Thursday, December 04 @ 17:37:31 CST by editor Daily_News

    Computers: Computer, Software, Hardware
    Computers: Computer, Software, Hardware

    In the two preceding parts of this tutorial we explained the basics of Rules and Conditions. We will now follow up with two examples to illustrate their use for somewhat more...

    Module mod_rewrite Tutorial (Part 3): Rewriting URLs by Dirk Brockhausen

    In the two preceding parts of this tutorial we explained the basics of Rules and Conditions.

    We will now follow up with two examples to illustrate their use for somewhat more complex applications.

    The first example deals with dynamicall generated pages while the second example will cover calling up ".txt" files.

    For our first example, let's assume that you want to sell several items of merchandise on your web site.

    Your clients are guided to various detailed product descriptions via a script:

    http://www.yoursite.com/cgi-bin/shop.cgi?product1 http://www.yoursite.com/cgi-bin/shop.cgi?product2 http://www.yoursite.com/cgi-bin/shop.cgi?product3

    These URLs are included as links on your site.

    If you want to submit these dynamic pages to the search engines, you are confronted with the problem that most of them will not accept URLs containing the "?" character.

    However, it would be perfectly possible to submit an URL of the following format:

    http://www.yoursite.com/cgi-bin/shop.cgi/product1

    Here, the "?" character has been replaced by "/".

    Yet more pleasing to the eye would be a URL of this type:

    http://www.yoursite.com/shop/product1

    To the search engine, this appears to be just another acceptable hyperlink, with "shop" presenting a directory containing files "product1", "product2", etc.

    If a visitor clicks this link on a search engine's results page, this URL must be reconverted to make sure that "shop.cgi?product1" will actually be called.

    To this effect we will make use of mod_rewrite with the following entries:

    RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^(.*)shop/(.*)$ $1cgi-bin/shop.cgi?$2

    The variables $1 and $2 constitute so-called "backreferences". These are related to text groups.

    Everything called in the clicked URL which is located before "shop" plus everything following "shop/" is defined by and stored in the two variables $1 and $2

    Up to this point our given examples made use of rules such as this one:

    RewriteRule ^.htaccess*$ - [F]

    However, we did not yet achieve a true rewrite in the sense that one URL would be switched to another.

    For the entry in our current example:

    RewriteRule ^(.*)shop/(.*)$ $1cgi-bin/shop.cgi?$2

    this general syntax applies:

    RewriteRule currentURL rewrittenURL

    As you can see, this command executes a real rewrite.

    In addition to installing the ".htaccess" file, all links in your normal HTML pages which follow the format "cgi-bin/shop.cgi?product" must be changed to: "shop/product" (without the quotes).

    When a spider visits a normal HTML page of this kind it will also follow or crawl the product links because there is no question mark contained in the link anymore to prevent it from doing so.

    So employing this method you can convert dynamically generated product descriptions into seemingly static web pages and feed them to the search engines.

    -

    In our second example we will discuss how to redirect calls for ".txt" files to a program script.

    Many webspace providers running Apache will feature system log files only in common format. What this means is that these logs will not store visitor Referrers and UserAgents.

    However, in relation to "robots.txt" calls it is preferable to have access to this information in order to learn more about visiting spiders than merely their IPa.

    To effect this, the entries in ".htaccess" should be as follows:

    RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^ obots.txt$ /text.cgi?%{REQUEST_URI}

    Now, when "robots.txt" is called, the applied Rule will redirect your visitor to the program script "text.cgi".

    Furthermore, a variable is conveyed to the script which will be processed by the program.

    "REQUEST_URI" defines the name of the file you expect to be called. In out example this is "robots.txt".

    The script will now read the contents of "robots.txt" and will forward them to the web browser or the search engine spider.

    Finally, the visitor hit is archived in the log file. To this effect, the script will pull the environmental variables "$ENV{'HTTP_USER_AGENT'}" etc. This will provide the required information.

    Here is the source code for the cgi script mentioned above:

    <BEGIN SOURCE CODE> #!/usr/bin/perl # If required, adjust line above to point to Perl 5. ##################################### # (c) Copyright 2000 by fantomaster.com # # All rights reserved. # #####################################

    $stats_dir = "stats"; $log_file = "stats.log";

    $remote_host = "$ENV{'REMOTE_HOST'}"; $remote_addr = "$ENV{'REMOTE_ADDR'}"; $user_agent = "$ENV{'HTTP_USER_AGENT'}"; $referer = "$ENV{'HTTP_REFERER'}"; $document_name = "$ENV{'QUERY_STRING'}";

    open (FILE, "robots.txt"); @TEXT = <FILE>; close (FILE);

    &get_date;

    &log_hits ("$date $remote_host $remote_addr $user_agent $referer $document_name ");

    print "Content-type: text/plain "; print @TEXT;

    exit;

    sub get_date { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(); $mon++; $sec = sprintf ("%02d", $sec); $min = sprintf ("%02d", $min); $hour = sprintf ("%02d", $hour); $mday = sprintf ("%02d", $mday); $mon = sprintf ("%02d", $mon); $year = scalar localtime; $year =~ s/.*?(d{4})/$1/; $date="$year-$mon-$mday, $hour:$min:$sec"; }

    sub log_hits { open (HITS, ">>$stats_dir/$log_file"); print HITS @_; close (HITS); }

    <END SOURCE CODE>

    To install the script, upload it to your web site's main or DocumentRoot directory by ftp and change file permissions to 755.

    Next, create the directory "stats".

    A more detailed description on how to install a script can he found in our online manuals, e.g. here:

    < http://www.fantomaster.com/fantomasSuite/logFrog/lfhelp.txt >

    If your server's configuration does not permit execution of Perl or CGI scripts in the main directory (DocumentRoot), you may wish to try the following RewriteRule instead:

    RewriteRule ^ obots.txt$ /cgi-bin/text.cgi?%{REQUEST_URI}

    Note, however, that in this case you will have to modify the paths accordingly in the program script!

    Finally, here's the solution to our quiz from the previous issue of fantomNews:

    RewriteCond %{REMOTE_ADDR} ^216.32.64 RewriteRule ^.*$ - [F]

    Quiz question: - If we don't write "^216.32.64." for a regular expression in the configuration above, but "^216.32.64" instead, will we get the identical effect, i.e. will this exclude the same IPs?

    The regular expression ^216.32.64 will apply e.g. to the following strings:

    216.32.64 216.32.640 216.32.641 216.32.64a 216.32.64abc 216.32.64.12 216.32.642.12

    Hence, "4" may be followed by any character string.

    However, IP addresses can only have the maximal value 255.255.255.255 - which implies that e.g. 216.32.642.12 is not a valid IP. The only valid IP in the list above is 216.32.64.12!

    Although the two regular expressions "^216.32.64." and "^216.32.64" allow for different strings, due to the technical limitation of IP addresses to 0-255 this range of IPs will remain excluded.

    (to be continued ...)

    Dirk Brockhausen is the co-founder and principal of fantomaster.com Ltd. (UK) and fantomaster.com GmbH (Belgium), a company specializing in webmasters software development, industrial-strength cloaking and search engine positioning services. He holds a doctorate in physics and has worked as an SAP consultant and software developer since 1994. He is also Technical Editor of fantomNews, a free newsletter focusing on search engine optimization, available at: < http://fantomaster.com/fantomnews-sub.html > You can contact him at mailto:fntecheditor@fantomaster.com (c) copyright 2000 by fantomaster.com

    You can reprint this article (if not stated otherwise above) on your website or publication with notice and a link to http://www.zongoo.com

    "Reprinted from Zongoo.com Daily Press & Consumer Information"

    Please copy and paste the following HTML Code to your page:

    "Reprinted from <a href="http://www.zongoo.com" target="_blank">Zongoo.com Daily Press & Consumer Information</a></b>"

    NOTE: If you find our site usefull, have used our articles, or submitted any article, please take a moment to add a link to our site by copy and paste the following html code at your web site:

    <a href="http://www.zongoo.com" target="_blank">Zongoo Daily Press & Consumer Information</a>


     
    Related links
    · Apache
    · ASP
    · Cold Fusion
    · CSS
    · Hosting
    · HTML
    · Javascript
    · MySQL
    · PHP
    · SSI
    · Website design
    · Perl/CGI
    · Search engines
    · Spam
    · Search on Computers: Computer, Software, Hardware
    · Search for stories contributed by editor Daily_News

    Most read story about Computers: Computer, Software, Hardware:
    Advantages of Email


    Rate article
    Average Score: 1
    Votes: 2


    Please take a second and vote for this article:

    Bad
    Regular
    Good
    Very Good
    Excellent



    Options

    Printer Friendly Page  Printer Friendly Page

    Send to a Friend  Send to a Friend

    Threshold
    The Zongments are owned by the poster. We aren't responsible for their content.

    No Zongments Allowed for Guests of Republic of Zongland, please declare citizenship

    Re: Module mod_rewrite Tutorial (Part 3) (Score: 1)
    by derekb on Tuesday, May 18 @ 09:59:46 CDT
    (User Info | Send a Message)
    how would i rewrite

    www.mysite.com/somefile.php?blah=somevar&blah2=somevar to go to
    www.mysite.com/somefile.php [www.mysite.com] with no query string or www.mysite.com/somedir [www.mysite.com] with no query string and all the www's would be optional of course.


    Copyright © Zongoo!.com, 2003-2004
    Based on PHP-Nuke
    Page Generation: 0.193 Seconds