<?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>Life &#187; htaccess</title>
	<atom:link href="http://life.co-hey.com/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://life.co-hey.com</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jan 2012 08:15:38 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ZendFrameworkの環境変数APPLICATION_ENVを設定する</title>
		<link>http://life.co-hey.com/2011/02/zendframework%e3%81%ae%e7%92%b0%e5%a2%83%e5%a4%89%e6%95%b0application_env%e3%82%92%e8%a8%ad%e5%ae%9a%e3%81%99%e3%82%8b/</link>
		<comments>http://life.co-hey.com/2011/02/zendframework%e3%81%ae%e7%92%b0%e5%a2%83%e5%a4%89%e6%95%b0application_env%e3%82%92%e8%a8%ad%e5%ae%9a%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 01:36:50 +0000</pubDate>
		<dc:creator>co-hey</dc:creator>
				<category><![CDATA[framework]]></category>
		<category><![CDATA[web & pc]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://life.co-hey.com/?p=945</guid>
		<description><![CDATA[ZendFrameworkでは、index.phpにもともと書いてある記述に以下の環境変数に関わるものがあります。 1 2 3 / Define application environment defined&#40;' [...]]]></description>
			<content:encoded><![CDATA[<p>
ZendFrameworkでは、index.phpにもともと書いてある記述に以下の環境変数に関わるものがあります。<br />
<br />

<div class="wp_codebox"><table><tr id="p9454"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p945code4"><pre class="php" style="font-family:Osaka-mono,monospace;"><span style="color: #339933;">/</span> <span style="color: #990000;">Define</span> application environment
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'production'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<br />
<br />
APPLICATION_ENVが設定されてなかったら、&#8217;production&#8217; という文字列を、APPLICATION_ENVとして設定するという内容です。このAPPLICATION_ENVはどこで使われているかというと、Bootstrap内で、application.iniを読み込む際に、パラメタとして渡されています。<br />
<br />
application.iniは、DB接続設定等を書くファイルで、APPLICATION_ENVの値を、本番環境、テスト環境等で変えることによって、ファイルを編集することなく、DB接続先の設定を環境に合ったものに設定することができます。iniファイルの書き方は、こちらをご参照ください(<a href="http://framework.zend.com/manual/1.11/ja/zend.config.adapters.ini.html">http://framework.zend.com/manual/1.11/ja/zend.config.adapters.ini.html</a>)<br />
<br />
今回、<strong>/etc/sysconfig/httpd</strong> に以下の記述を追加すると、apacheにて環境変数を追加することができました。<br />
<br />

<div class="wp_codebox"><table><tr id="p9455"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p945code5"><pre class="sh" style="font-family:Osaka-mono,monospace;">export APPLICATION_ENV=&quot;development&quot;</pre></td></tr></table></div>

<br />
<br />
.htaccessを使うと、&#8221;setEnv&#8221;を使って記述することもできます。その場合の書き方は以下になります。<br />
<br />

<div class="wp_codebox"><table><tr id="p9456"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p945code6"><pre class="htaccess" style="font-family:Osaka-mono,monospace;">setEnv APPLICATION_ENV development</pre></td></tr></table></div>

<br />
<br />
これまで、.htaccessを使ったやり方のみでやってきて、/etc/sysconfig/httpd を編集する方法を知りませんでした。</p>

<a href="http://twitter.com/?status=RT%20%40%3A%20ZendFramework%E3%81%AE%E7%92%B0%E5%A2%83%E5%A4%89%E6%95%B0APPLICATION_ENV%E3%82%92%E8%A8%AD%E5%AE%9A%E3%81%99%E3%82%8B%20-%20Life%20http%3A%2F%2Ftinyurl.com%2F4jgqbza&amp;in_reply_to_status_id=32251003998834688" class="tweet-this" ><img src="http://life.co-hey.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="つぶやく" alt="つぶやく" /></a>]]></content:encoded>
			<wfw:commentRss>http://life.co-hey.com/2011/02/zendframework%e3%81%ae%e7%92%b0%e5%a2%83%e5%a4%89%e6%95%b0application_env%e3%82%92%e8%a8%ad%e5%ae%9a%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>htaccessでredirectする際に、パラメタ(query string)を引き継ぐ</title>
		<link>http://life.co-hey.com/2010/06/htaccess%e3%81%a7redirect%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e3%80%81%e3%83%91%e3%83%a9%e3%83%a1%e3%82%bfquery-string%e3%82%92%e5%bc%95%e3%81%8d%e7%b6%99%e3%81%90/</link>
		<comments>http://life.co-hey.com/2010/06/htaccess%e3%81%a7redirect%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e3%80%81%e3%83%91%e3%83%a9%e3%83%a1%e3%82%bfquery-string%e3%82%92%e5%bc%95%e3%81%8d%e7%b6%99%e3%81%90/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 00:00:13 +0000</pubDate>
		<dc:creator>co-hey</dc:creator>
				<category><![CDATA[web & pc]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://life.co-hey.com/?p=646</guid>
		<description><![CDATA[wordpressを使うとき等に、htaccessにはお世話になってますが、以前$_GETをrewrite_condでひっかけて、redirect先へ引き継ごうとして、断念していました。 どうしても、正規表現でquery [...]]]></description>
			<content:encoded><![CDATA[<p>
wordpressを使うとき等に、htaccessにはお世話になってますが、以前$_GETをrewrite_condでひっかけて、redirect先へ引き継ごうとして、断念していました。<br />
どうしても、正規表現でquery string(?key=valueの部分)がひっかけれなくて。<br />
<br />
その時は無理矢理、http://test.com/key/value/の形式にリダイレクトして、プログラム側で、REQUEST_URIから、パラメタ名と、値を取得したんですが、今回いいものを見つけました。<br />
<br />
それが、<b>QSA</b>オプション。Query Strins Appendの略です。<br />
これをつけておくと、リダイレクトをかけても、そのままquery stringも引き継いでくれます。しかも、redirect時に、自分でquery stringを付け足しても、うまいこと後付してくれる賢さです。<br />
<br />
<a href="http://www.hoge256.net/2008/04/119.html">http://www.hoge256.net/2008/04/119.html</a><br />
<br />
サンプルはこんな感じ。<br />
<br />

<div class="wp_codebox"><table><tr id="p6468"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p646code8"><pre class="php" style="font-family:Osaka-mono,monospace;">RewriteEngine On
&nbsp;
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> ^<span style="color: #339933;">/</span>test<span style="color: #339933;">/</span>
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span>js<span style="color: #339933;">|</span>ico<span style="color: #339933;">|</span>gif<span style="color: #339933;">|</span>jpg<span style="color: #339933;">|</span>png<span style="color: #339933;">|</span>css<span style="color: #339933;">|</span>html<span style="color: #009900;">&#41;</span>$
RewriteRule ^<span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ <span style="color: #339933;">/</span> <span style="color: #009900;">&#91;</span>P<span style="color: #339933;">,</span>L<span style="color: #339933;">,</span>QSA<span style="color: #009900;">&#93;</span></pre></td></tr></table></div>

<br />
</p>

<a href="http://twitter.com/?status=RT%20%40%3A%20htaccess%E3%81%A7redirect%E3%81%99%E3%82%8B%E9%9A%9B%E3%81%AB%E3%80%81%E3%83%91%E3%83%A9%E3%83%A1%E3%82%BF%28query%20string%29%E3%82%92%E5%BC%95%E3%81%8D%E7%B6%99%E3%81%90%20-%20Life%20http%3A%2F%2Ftinyurl.com%2F2gxuzvg" class="tweet-this" ><img src="http://life.co-hey.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="つぶやく" alt="つぶやく" /></a>]]></content:encoded>
			<wfw:commentRss>http://life.co-hey.com/2010/06/htaccess%e3%81%a7redirect%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e3%80%81%e3%83%91%e3%83%a9%e3%83%a1%e3%82%bfquery-string%e3%82%92%e5%bc%95%e3%81%8d%e7%b6%99%e3%81%90/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

