Apache mod_rewrite

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Apache mod_rewrite - Presentation Transcript

    1. Apache mod_rewrite Dave Ross The West Suburban Chicago PHP Meetup April 3, 2008
    2. mod_rewrite is an Apache module that takes what the browser requests and “rewrites” it into something else before the other Apache modules see it
    3. Request Apache Request mod_rewrite Apache directives Other modules
    4. mod_rewrite directives can go in the Apache config file (httpd.conf)‏ or in an .htaccess file if I have to put them in httpd.conf, I usually make a separate file and include it Include rewrite_rules.conf
      • RewriteEngine on|off
      • RewriteCond
      • RewriteRule
      The main mod_rewrite directives: They're all you need to get started.
    5. RewriteCond {string} {pattern} [{flags}] {string} is a mod_rewrite variable. Usually, you'll use %{REQUEST_URI}. {pattern} is:
      • An extended regular expression (ereg)‏
      • A lexical test (>, <, or =)‏
      • -d (is directory?)‏
      • -f (is regular file?)‏
      • -l (is symlink?)‏
      • other lesser-used values
      {flags} are NC (“no case”) or OR (“this condition or the next one”)‏
    6. RewriteRule {pattern} {substitution} [{flags}] {pattern} is regular expression to match {substitution} is a string to replace that URL with. It can contain variables, reference parts of the {pattern}, or it can be the special “no substitution” string: - {flags} let you define behavior, like making the browser [R]edirect to the rewritten URL, telling the browser the page is [G]one, or returning a certain MIME [T]ype.
    7. For a full list of RewriteCond and RewriteRule options, read the docs at: Get really nice “cheat sheets” you can print at:
    8. mod_rewrite is mostly used to implement “friendly” URLs. They go by many names:
      • Friendly URLs
      • Search Engine Friendly URLs
      • Rational URLs
      • Permalinks
    9. Search engines like “friendly” URLs. How else are they supposed to know index.php?postid=6 is a different page than index.php?postid=7 ?
    10. Programs like WordPress and Drupal have support built-in. They'll even write the .htaccess for you. How sweet is that?
    11. Another common use of mod_rewrite is to map old URLs to new URLs
    12. Say you change your CMS... Search engines have links, and users have bookmarks to pages in your old CMS. You don't want 404 Not Found errors when they visit those URLs again. So you use mod_rewrite to convert URLs in one format to another
    13. Need More Info? There's a mod_rewrite tutorial at: This site not only has a tutorial, it has an active message board just about mod_rewrite:

    + Dave RossDave Ross, 2 years ago

    custom

    1322 views, 2 favs, 2 embeds more stats

    An introduction to Apache's mod_rewrite module

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1322
      • 1310 on SlideShare
      • 12 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 27
    Most viewed embeds
    • 11 views on http://suburbanchicagophp.org
    • 1 views on http://www.techiegyan.com

    more

    All embeds
    • 11 views on http://suburbanchicagophp.org
    • 1 views on http://www.techiegyan.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories