Newest SITEDESIGN Bookmarks

 

 

 
Newest Twitters

     

    Newest SITEDESIGN Blog Items

     
    htaccess excerpts and notes

    Here are some excerpts from my .htaccess files. I'm posting these because I often need to remember the syntax of these commands and it's easier to look at the commands here on my blog than to ssh to my DreamHost or Verio web-hosting account and look at them there. Also, I hope these excerpts and notes will be useful to others.

    Note: In the code below, a line that begins with a single hash (#) is code that is commented out and a line that begins with two hashes (##) is a comment about the code.

    Used Everywhere
    ## Block viewing of .htaccess files
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>

    ## Do not let IP address xxx.xxx.xxx.xx access (GET) the site
    ## Uncomment these 5 lines if someone or something is abusing the site
    ## Note: 'GET' can be replaced by 'GET POST PUT'
    # <Limit GET>
    # order allow,deny
    # allow from all
    # deny from xxx.xxx.xxx.xx
    # </Limit>

    ## If a directory is requested, do not list the files in the directory
    Options -Indexes

    ## Next is sometimes needed, but might already be set in the server configuration
    # AddDefaultCharset UTF-8

    ## Next is needed if you use Rewrite rules
    ## (examples of RewriteCond and RewriteRule are in the sections below)
    RewriteEngine On

    ## Next Rewrite option is often already set in the server configuration
    ## Uncomment if Rewrite rules don't work
    # Options +FollowSymLinks


    The next sections include examples that use the Apache mod_rewrite module. If they seem confusing, it's because they are! As Brian Behlendorf, one of the primary developers of the Apache web server, said:
    The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail.
    This quote, along with some other good quotes, is on the Apache Documentation mod_rewrite page.


    Used at Deflexion.com
    ## Specify the MIME type of unknown file extensions
    ## This is needed because I use extensionless URLs at Deflexion.com
    ## If default is HTML, use:
    # DefaultType text/html
    ## If default is PHP, use:
    DefaultType application/x-httpd-php

    ## If URL points to a directory, serve the first of these files that exist
    DirectoryIndex index index.php index.html index.atom

    ## PHP include files are located in this directory
    php_value include_path "/path/i/do/not/want/to/publish/on/my/blog/_shared"

    ## If 'http://deflexion.com/index' is requested, remove 'index'
    ## The goal is to get people & machines to link to 1 & only 1 URL for this page
    ## Details at Wikipedia's URL normalization
    ## More examples of URL canonicalization are in the Infinite Ink section below
    ## Note: '^[A-Z]{3,9}\ /' matches GET POST PROPFIND etc, followed by space slash
    ## This RewriteCond avoids infinite loops
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\ HTTP/
    RewriteRule ^index$ http://deflexion.com/ [R=301,L]

    ## Redirect this local URL-path to the current URL
    Redirect permanent /messaging/blogs/ http://deflexion.com/2004/01/just-what-is-blog-atomizing

    ## For details about these RedirectMatch lines, see
    ## Twitter, TinyURL, Dots, Dashes, and My htaccess File
    ## Note: The order of these 5 RedirectMatch lines matters!
    RedirectMatch 301 ^/(2008/../[^.]*)\.([^.]*)\.([^.]*)\.([^.]*)\.([^.]*)\.([^.]*)$ http://deflexion.com/$1-$2-$3-$4-$5-$6
    RedirectMatch 301 ^/(2008/../[^.]*)\.([^.]*)\.([^.]*)\.([^.]*)\.([^.]*)$ http://deflexion.com/$1-$2-$3-$4-$5
    RedirectMatch 301 ^/(2008/../[^.]*)\.([^.]*)\.([^.]*)\.([^.]*)$ http://deflexion.com/$1-$2-$3-$4
    RedirectMatch 301 ^/(2008/../[^.]*)\.([^.]*)\.([^.]*)$ http://deflexion.com/$1-$2-$3
    RedirectMatch 301 ^/(2008/../[^.]*)\.([^.]*)$ http://deflexion.com/$1-$2
    ^^^
    '301' is equivalent to 'permanent'


    Used at Infinite Ink
    ## If the requested hostname is anything other than www.ii.com,
    ## rewrite it to www.ii.com
    RewriteCond %{HTTP_HOST} !^www.ii.com$
    RewriteRule (.*) http://www.ii.com/$1 [R=301,L]

    ## Remove trailing 'index.html' from requested URLs
    ## See Note above about the regular expression '^[A-Z](3,9}\ /'
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.html$ http://www.ii.com/$1 [R=301,L]

    ## Redirect this local URL-path to the current URL
    Redirect permanent /communicate http://deflexion.com/2005/12/make-meta-comment


    Comments, suggestions, and questions are welcome!

    Libellés : , , , , , , , ,


     
    consider reworking your entire website's content

    Thank you to Greenman for inspiring me to start cleaning up my web pages. Here is an excerpt of an email message he sent me, which I'm posting with permission.
    with regards to the page: http://www.ii.com/internet/robots/procmail/qs/
    also page: http://www.ii.com/internet/messaging/imap/isps/

    Greetings, and thank you for this wonderful information! However, I nearly dismissed it as a simple news aggregator site only. The news and metanotes take up so much room at the top, I began wondering whether there really was any content about procmail. Such excellent content shouldn't be so horribly strangled to oblivion by its layout. . . . Please - please - consider reworking your entire website's content. . . .
    I've known for a long time that I need to do this and this Deflexion.com site was actually created "for experimenting with tools and designs that might be used for the redesign of the Infinite Ink site." A major reworking is going to happen, but for now I'm cutting down the news and metanotes sections of my pages, starting with the Procmail Quick Start. The news that used to be on that page is now located on this blog in a blog item titled September 2003 - March 2007 News from the Procmail Quick Start.

    Libellés :


     
    September 2003 - March 2007 News from the Procmail Quick Start

    A few days ago I removed the Procmail-Related News and Advertisements section from my Procmail Quick Start. For historical purposes, here are the News items. I haven't decided what I'm going to do with the Advertisements, but I'm thinking I'm going to switch to a little donation button. As you can see from my Anti-Phishing Email Address Strategy blog post that I posted more than a year ago, it takes me a long time to make a decision like this!

    Libellés : , , , , ,


     
    Blogger, PHP, and Labels

    I'm in the process of updating my Blogger template so that my new Blogger labels and their corresponding label pages have a reasonable user interface and are actually useful. My goals are to:
    • Make it clear when a label page is being displayed by including the label name in the page title and in any relevant headers & sidebar sections.
    • On the page for a label named label, display my bookmarks that are tagged with label on del.icio.us (and, of course, also display my blog items that are labeled with label).
    The first step is to use PHP to get the label name into a variable, which I call $label. Here's how I do this:
    <MainPage>
    <?php
    $label = strtoupper(basename($_SERVER['PHP_SELF']));
    if ($label == 'INDEX') {
    $label = NULL;
    }

    // Note: This assumes no label will be named index

    ?>
    </MainPage>
    This sets the $label variable to the upper-cased label name if a label page is being displayed and to NULL if the top page (deflexiοn.com/index) is being displayed. Determining the label name is as simple as determining the page's filename (basename) because Blogger names each label page label.extension and I've set up my blog to use extensionless URLs.

    Once the variable $label is set, I use code such as the following to unconditionally process statements:
    <?php
    echo "$label Deflexions (bookmarks)";
    ?>
    Note that this does the right thing on label pages and on the the top page (index). For example, on a label page this resolves to:
    LABEL Deflexions (bookmarks)
    And on the top page, this resolves to:
    Deflexions (bookmarks)
    To conditionally process statements, I use code like the following:
    <?php
    if ($label) {
    echo "↓ deflexions & reflexions labeled $label";
    }
    ?>
    Note that on the top page $label is NULL, which is considered FALSE, and statements inside the squiggly brackets will not be run.

    I'm still updating my template so things are kind of a mess at the moment. I'm posting this now because I'd love to get feedback on my PHP code and my template. Please post your thoughts and tips as a comment to this blog item - thank you!

    Libellés : , , ,


     
    Blogger permalinks seem permanent, but are they?

    I think I've now set up Blogger and the .htaccess file [*] at my web-hosting provider so that all the reflexion archive-page URLs and the new reflexion item-page URLs (permalinks) have no extension. I want this because I don't want to be locked in to the .php extension that I've been using, for example, I might switch from PHP to another scripting language at some point in the future, and because extensionless URLs are nice [**].

    What I want, but haven't been able to figure out how to do, is to change the permalink of all my old reflexions. Does anyone know how to do this in Blogger or via the Blogger API? I tried turning off "Post Pages", republishing, turning "Post Pages" back on, and republishing again, but Blogger remembers the old permalinks. I can understand why the Blogger developers would do this, since they are supposed to be permalinks, but I've used these URLs for less than a week and I can solve the problem of broken bookmarks and broken links via .htaccess tricks.

    If anyone has any suggestions, please leave a comment here. Or just leave a comment so I know that someone has read this -- don't be shy!

    Update: It turns out that when I edit an old reflexion and then republish it, it gets a new extensionless URL. I'm slowly going through my old posts and turning on comments, removing extraneous newlines, and republishing with extensionless URLs.

    [*] I use the following .htaccess lines tell the Apache web server that file names with no extension are to be interpreted as PHP files:
      DefaultType application/x-httpd-php
    DirectoryIndex index index.php index.html
    [**] To learn about the value of permalinks and extensionless URLs, see:

    Libellés : , , ,


     

     

    Each item © Nancy McGough
    Each comment © the author of the comment
    Deflexion.com web site hosted by DreamHost.com
    deflexions powered by del.icio.us · reflexions powered by Twitter & Blogger
    ← More deflexions & reflexions, & feeds available via the sidebar top & bottom