Pretty permalinks (url rewriting) info and links Print Friendly Version of this pagePrint Get a PDF version of this webpagePDF 1-pretty_permalinks-info_and_links.html — rev 17 October 2014 ➽ back to dir

Some words to know ...

    url rewriting - the technical term for it.
    pretty permalinks - what WordPress calls it.

    Also known as: 
        Rewritten URLs, short URLs, fancy URLs, SEF (search engine friendly).

    mod_rewrite - the module (additional code) for apache that makes it work.

________________________________________________________________
What is url rewriting?

  All web programming (not just wordpress) works with query strings or pathinfo.
  This is useful and efficient - but not pretty to look at in the browser
  address bar. Also not so useful for people to figure out.

  So there is a way to translate "pretty" urls in the address bar,
  to the useful query strings that the program needs.

  In WordPress, we can redirect all URLs to WordPress index.php -- then
  WordPress breaks the URL into parts and uses regular expressions to
  translate into the query string that tells WordPress what to display.


________________________________________________________________
How to make them work?

  - Apache config: The "mod_rewrite_module must be enabled in apache web server
      (You shouldn't have to worry about this -- on any good web host,
       this is enabled. For your local install, you may have to
       enable it, depending on how your apache is installed.)

  - WordPress admin: Enable permalinks from WordPress Settings/Permalinks panel.
       - If it is set to Default, permalinks are disabled. 
         With any other value, they are active.

  - .htaccess file: Rewrite codes are saved by WordPress in a file called
       .htaccess in the document root of your site.
       If file permissions prevent WordPress from writing this file,
       you can make the file yourself, copy the codes from the Wordpress 
       permalinks page, and paste them in. 

________________________________________________________________
A good start ...

  How does WordPress URL rewriting work?  [Millian, Dev4Press.com - March 2012]
    Dev4Press.com/2012/tutorials/wordpress/practical/how-wordpress-url-rewriting-works/
    The basics of how it works.

  Using Permalinks (URL rewriting) for WordPress
    Codex.wordpress.org/Using_Permalinks
    The word, for WordPress, at the Codex.

  Solving permalinks problems in WordPress - Forum
    WordPress.org/tags/url-rewrite


________________________________________________________________
Learning more about how it works ...

  Very excellent explanation of URL rewriting Smasing Mag - November 2011]
    Coding.SmashingMagazine.com/2011/11/02/introduction-to-urlrewriting/
    What it is; how it helps; rewriting syntax and regular expressions;
    examples; how it works in wordpress; more.
    [gotit]

  Another excellent explanation: [2008]
    AddedBytes.com/for-beginners/url-rewriting-for-beginners/
    Good step-by-step explanation with examples; useful links.
    Good questions and problems in comments.

________________________________________________________________
References and Cheatsheets:

  The Apache reference documentation:
    Httpd.Apache.org/docs/2.0/mod/mod_rewrite.html

  mod_rewrite Cheatsheet, as HTML and PDF:
    Cheatography.com/davechild/cheat-sheets/mod-rewrite/

________________________________________________________________
Going deeper ...

  URL Rewriting Guide - at Apache.org
    Httpd.Apache.org/docs/2.0/misc/rewriteguide.html
    Practical uses, with explanations and solutions.

  "Rewrite engine", at Wikipedia
    en.Wikipedia.org/wiki/Rewrite_engine