Apache module mod_rewrite

さらに、mod_rewrite ではパターンの前に NOT 文字('!') が使えます。これで後続のパターンを否定することができます。たとえて 言うならば、``もし現在の URL がこのパターンにマッチ しなければpattern'' ということです。これは、反対の パターンを表す方が簡単だったり、最後のデフォルトルールとするなど、 例外的なケースを表現するのにも使えます。

ApacheウェブサーバーのRewrite設定で使える正規表現サンプル集 | Web担当者Forum

ブログ記事に付けられる番号パラメータのURLを静的URLでアクセスできるようにしたい

ブログやCMSなど、記事を投稿するごとに番号が振られるシステムを利用している場合の、記事ページに自動的に付加されるパラメータを擬似静的化します。見た目は静的なURLですが、裏ではpost.phpというプログラムにパラメータを渡して処理しています。

ApacheウェブサーバーのRewrite設定で使える正規表現サンプル集 | Web担当者Forum

「www」の有無を統一したい

  • 仕様
    http://example.com/http://www.example.com/
    wwwなしでアクセスがあったら、wwwありに301リダイレクトさせる
  • サンプルコード
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

URLの正規化の記事で説明したとおり、URLはwwwあり、もしくはwwwなしのどちらかに統一する必要があります。もし検索エンジンに両方認識されてしまった場合には上記のように設定します。

Fedora12にMercurialを入れてみる - tanamonの日記

再度push

pushing to http://192.168.30.46/hg/
searching for changes
1 changesets found
abort: authorization failed
[command interrupted]

またエラー


# vi .hg/hgrc
[web]
push_ssl = false
allow_push = *

誰でもpushできるように設定。


再々度push

pushing to http://192.168.30.46/hg/
searching for changes
1 changesets found
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
[command completed successfully Mon Dec 07 13:31:03 2009]

今度は通った。

Apache Log Analyzer 2 Feed - Index - Simone Carletti's Codestuffs

Apache Log Analyzer 2 Feed

ApacheLogAnalyzer2Feed is a really powerful open source PHP 5 class to parse and analyze Apache Web Server log files. Results are converted into a feed to let users subscribe them with a feed reader.

You can define custom filters based on logs data — for instance User-Agent, IP, requested page... — and combine them to select just a limited resultset.
The class can easily be extended with additional filters and custom feed handlers.

Quick Start

Would you like to be informed each time GoogleBot visits your website?

ApacheLogAnalyzer2Feed is the solution! ApacheLogAnalyzer2Feed will analyze server logs for you returning results in a custom feed.
Simply using the following code fragment you'll be able to track Googlebot directly from your feed reader.

@IT:Apacheでユーザー認証を行うには(Basic認証編)

 なお、初めて.htpasswdファイルを作成するときは-cオプションが必要となる。

# htpasswd -c /etc/httpd/.htpasswd secret
New password:
Re-type new password:
Adding password for user secret

 そして、Apacheの設定ファイル(/etc/httpd/conf/httpd.conf)に以下の設定を追加する。

<Directory "/var/www/html/member">
    AuthType Basic
    AuthName "Secret Zone"
    AuthUserFile /etc/httpd/.htpasswd
    Require user secret
</Directory>