<?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>Mihalytch personal blog &#187; rewritecond</title>
	<atom:link href="http://mihalytch.org.ua/tag/rewritecond/feed" rel="self" type="application/rss+xml" />
	<link>http://mihalytch.org.ua</link>
	<description>Все о высоких технологиях</description>
	<lastBuildDate>Mon, 05 Dec 2011 16:05:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>WP Super Cache &#8211; rewrite rules для nginx</title>
		<link>http://mihalytch.org.ua/administration/wpsupercache-rewrite-rules-for-nginx.html</link>
		<comments>http://mihalytch.org.ua/administration/wpsupercache-rewrite-rules-for-nginx.html#comments</comments>
		<pubDate>Fri, 28 Nov 2008 10:47:51 +0000</pubDate>
		<dc:creator>mihal</dc:creator>
				<category><![CDATA[Администрирование]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Cookie]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rewritecond]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://mihalytch.org.ua/administration/wpsupercache-rewrite-rules-for-nginx.html</guid>
		<description><![CDATA[Если вы решились прочитать это пост, значит вы решили перейти (или уже перешли, что вероятнее всего) с  apache на nginx. [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float:left; margin:5px;" src="http://mihalytch.org.ua/wp-content/nginx.gif" alt="nginx" />Если вы решились прочитать это пост, значит вы решили перейти (или уже перешли, что вероятнее всего) с  apache на nginx. Движок вашего сайта WordPress, и необходимо использовать плагин &#8220;WP Super Cache&#8221;. Текущая статья посвящена тому, как настроить rewrite rules под nginx.<span id="more-68"></span></p>
<p>Super Cache после установки и активации попросит нас сделать .htaccess доступным для записи или записать в него следующие правила:</p>
<pre class="brush: plain; title: ; notranslate">
# BEGIN WPSuperCache
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
&lt;/IfModule&gt;
# END WPSuperCache
</pre>
<p>Но проблема в том, что все эти правила, как и сам .htaccess, абсолютно бесполезны для nginx`a, так как все rewrite rules прописываются в nginx.conf.</p>
<p>Итак  открываем файл конфигурации nginx.conf, находим</p>
<pre class="brush: plain; title: ; notranslate">
location /путь/к/блогу/ {
...
}
</pre>
<p>&#8220;/путь/к/блогу/&#8221; &#8211; вот вместо этого, скорее всего, будет стоять просто &#8220;/&#8221;</p>
<p>и между фигурными скобочками вписываем ряд директив:</p>
<pre class="brush: plain; title: ; notranslate">
gzip_static on;
if (-f $request_filename) {
 break;
}  

set $supercache_file '';
set $supercache_uri $request_uri;  

if ($request_method = POST) {
 set $supercache_uri '';
}  

if ($query_string) {
 set $supercache_uri '';
}  

if ($http_cookie ~* &quot;comment_author_|wordpress|wp-postpass_&quot; ) {
 set $supercache_uri '';
}  

if ($supercache_uri ~ ^(.+)$) {
 set $supercache_file /blog/wp-content/cache/supercache/$http_host/$1index.html;
}  

if (-f $document_root$supercache_file) {
 rewrite ^(.*)$ $supercache_file break;
}  

if (!-e $request_filename) {
 rewrite . /blog/index.php last;
}
</pre>
<p>Сохраняем и перезапускаем сервер.</p>
<p>P.S. Если мы хотим пользоваться gzip компрессией, то необходимо будет перекомпилировать nginx с параметром &#8220;<em>–-with-http_gzip_static_module</em>&#8220;.</p>
]]></content:encoded>
			<wfw:commentRss>http://mihalytch.org.ua/administration/wpsupercache-rewrite-rules-for-nginx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

