<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.maru.cc &#187; Apache</title>
	<atom:link href="http://blog.maru.cc/archives/category/programing/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.maru.cc</link>
	<description>くるくる回せ</description>
	<lastBuildDate>Sat, 23 Oct 2010 16:53:26 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>VirtualHost設定 wwwありでもアクセスさせる方法</title>
		<link>http://blog.maru.cc/archives/84/</link>
		<comments>http://blog.maru.cc/archives/84/#comments</comments>
		<pubDate>Thu, 27 Sep 2007 18:22:11 +0000</pubDate>
		<dc:creator>maru_cc</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.maru.cc/archives/84</guid>
		<description><![CDATA[一般的に、Webサイトの場合、ドメイン以外にwww付きでもアクセスさせる場合が多い。

example.com
www.example.com

といった具合だ。
通常その場合、Apacheならば、httpd.confに [...]]]></description>
			<content:encoded><![CDATA[<p>一般的に、Webサイトの場合、ドメイン以外にwww付きでもアクセスさせる場合が多い。</p>
<ul>
<li>example.com</li>
<li>www.example.com</li>
</ul>
<p>といった具合だ。</p>
<p>通常その場合、Apacheならば、httpd.confにて、virtualhost設定でServerAlias ディレクティブで設定することで実現できる。<br />
example.comが基本の場合</p>
<pre>
&lt;virtualhost *:80&gt;
    DocumentRoot /path/to/htdocs
    ServerName example.co.jp
    ServerAlias www.example.com
&lt;/virtualhost&gt;
</pre>
<p><a href="http://httpd.apache.org/docs/2.0/ja/mod/core.html#serveralias" class="_blank">http://httpd.apache.org/docs/2.0/ja/mod/core.html#serveralias</a></p>
<p>たまにこんな要望があったりすることがある。<br />
example.comドメインだけを見せたくて、www.example.comにアクセスされた場合にも、example.comを表示したい。という要望だ。<br />
通常通り、virtualhost設定をし、そこでリダイレクトの設定をすることも出来るが、virtualhost設定内で済ませることも出来る。</p>
<pre>
&lt;virtualhost *:80&gt;
    DocumentRoot /path/to/htdocs
    ServerName example.co.jp
&lt;/virtualhost&gt;
&lt;virtualhost *:80&gt;
    ServerName www.example.co.jp
    RewriteEngine on
    RewriteRule ^(.*) http://example.co.jp$1 [R=301]
&lt;/virtualhost&gt;
</pre>
<p>ステータスコードとして301を返すことで、永続的な移転ということを知らせることも出来る。</p>
<p>これの設定をするためにいろいろ試していたが、DocumentRoot設定がなくてもいいんだね。知りませんでした。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.maru.cc/archives/84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

