Newest
SYSADMIN
Bookmarks
- More than 10,000 bookmarks at http://Del.icio.us/Deflexion.com/SYSADMIN
-
Subscribe to
SYSADMIN
deflexions
or all
deflexions
Newest
SYSADMIN
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 (
Used Everywhere
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:
Used at Deflexion.com
Used at Infinite Ink
Comments, suggestions, and questions are welcome!
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 : apache, htaccess, mime, php, regex, regularexpressions, sitedesign, sysadmin, urls
Building and Installing Alpine (Apache-Licensed Pine)
Alpine, the University of Washington's new Apache-Licensed Pine, has been in alpha testing since 2006 November 29 and it's now at a point where I feel comfortable recommending it to power Pine users. If you would like to participate in the alpha test, go to the Alpine Information Center and join the alpine-alpha mailing list.
Here is what I did to build and install Alpine on my Mac OS X system.
Tip 1: You should be able to use a modified version of these instructions to build Alpine on any Unix-like system. For example, I used Steps 3-11 to build Alpine on my DreamHost shared hosting account, which runs Debian Linux.
Tip 2: The Alpine FTP site includes pre-built versions of Alpine for MS Windows (PC-Alpine): alpine-x.xx-wnt.zip and setup_alpine_x.xx.exe. Details are in ftp://ftp.cac.washington.edu/alpine/README
See Also: Paul Heinlein's Pine and Alpine on Mac OS X, which includes notes on building and running Pine or Alpine under Mac OS X.
Here is what I did to build and install Alpine on my Mac OS X system.
- If you have not done so already, download and install the latest Xcode package from the Apple Developer Center.
- Backup any Pine and Alpine files that are in /usr/local/bin. These will be replaced by Step 12 below.
- Go to ftp.cac.washington.edu/alpine and get the latest alpine-x.xx.tar.bz2 (where x.xx is the version number). I prefer to get the .bz2 file because it is smaller than the .Z and .gz files.
- Put this tarball in your build directory, for example in ~/Build.
- Open a Terminal window.
- To change to your build directory, type:
cd ~/Build
- To check the MD5 checksum of the tarball, run one of the following commands:
/sbin/md5 /absolute/path/to/alpine-x.xx.tar.bz2
I recommend that you specify the absolute path to both the command and the tarball to ensure you are not specifying trojans. The MD5 checksum should match the MD5 checksum that is in the x.xx release announcement message in the alpine-alpha mailing list.
/usr/bin/openssl md5 /absolute/path/to/alpine-x.xx.tar.bz2 - To unbzip2 and untar the tarball, type:
tar jxvf alpine-x.xx.tar.bz2
- To change to the newly created alpine-x.xx directory, type:
cd alpine-x.xx
- To read the README and the configuration help, type:
less README
./configure --help |less - To build Alpine, type the following (which are discussed in the README):
./configure
make - After the build is finished, type:
sudo make install
You will be prompted for your Mac OS X password. - To check that Alpine was built and installed correctly, type:
man alpine
Make sure that these two commands invoke the correct version (x.xx). If these commands do not work, you probably need to add /usr/local/man to your MANPATH environment variable and /usr/local/bin to your PATH environment variable. For details, see the man page for your shell (man bash, man tcsh, etc.). To determine your shell, run finger -l.
alpine
- man alpine
- alpine -h | less
- Alpine Release Notes, which can be viewed by typing MR (Main > RelNotes) in Alpine
- Alpine's built-in context-sensitive Help, which can be viewed by typing ^G (Get Help) or ? in Alpine
- Alpine-alpha list archives
- All About Pine: POP, IMAP, NNTP, & ESMPT Client for Unix, MS Windows, and Mac OS X
- Power Pine: Getting the Most Out of Unix-, Mac-, and PC-Pine
Tip 1: You should be able to use a modified version of these instructions to build Alpine on any Unix-like system. For example, I used Steps 3-11 to build Alpine on my DreamHost shared hosting account, which runs Debian Linux.
Tip 2: The Alpine FTP site includes pre-built versions of Alpine for MS Windows (PC-Alpine): alpine-x.xx-wnt.zip and setup_alpine_x.xx.exe. Details are in ftp://ftp.cac.washington.edu/alpine/README
See Also: Paul Heinlein's Pine and Alpine on Mac OS X, which includes notes on building and running Pine or Alpine under Mac OS X.
Libellés : alpine, email, imap, nntp, osx, sysadmin
Each item © Nancy McGough
Each comment © the author of the comment
Deflexion.com web site hosted
by DreamHost.com
←
More deflexions & reflexions, & feeds
available via the sidebar
top
&