<?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>Nicolas Kuttler &#187; apache</title>
	<atom:link href="http://www.nkuttler.de/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nkuttler.de</link>
	<description>WordPress Services, IT Services</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:49:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Password protecting the wp-admin directory</title>
		<link>http://www.nkuttler.de/2010/06/14/htaccess-protect-wordpress-admin/</link>
		<comments>http://www.nkuttler.de/2010/06/14/htaccess-protect-wordpress-admin/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 13:16:07 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de/?p=1584</guid>
		<description><![CDATA[Several places recommend to block the WordPress admin area with a password. While this certainly is a good idea, implementing it properly is non-trivial. One of the problems is that the WordPress Ajax handler script is located in the admin directory. So password-protecting the admin area will break all Ajax functionality your blog might be [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codex.wordpress.org/Hardening_WordPress">Several</a> <a href="http://wordpress.tv/2009/07/11/brad-williams-security-montreal09/">places</a> recommend to block the WordPress admin area with a password. While this certainly is a good idea, implementing it properly is non-trivial. <span id="more-1584"></span></p>
<p>One of the problems is that the WordPress Ajax handler script is located in the admin directory. So password-protecting the admin area will break all Ajax functionality your blog might be using.</p>
<p>First, see <a href="http://httpd.apache.org/docs/2.2/howto/auth.html">this tutorial</a> on how to password protect directories with an <tt>.htaccess</tt> file. <a href="http://sivel.net">Sivel</a> has an <a href="http://core.trac.wordpress.org/ticket/12400#comment:23">example</a> for whitelisting the Ajax handler, add these line to your <tt>.htaccess</tt> file:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># These are the lines that do the password protection.</span>
<span style="color: #adadad; font-style: italic;"># You probably already created them while reading through the tutorial linked above.</span>
<span style="color: #00007f;">AuthUserFile</span> /path/to/your/htpasswd
<span style="color: #00007f;">AuthType</span> basic
<span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;Restricted Resource&quot;</span>
<span style="color: #00007f;">require</span> valid-<span style="color: #00007f;">user</span>
&nbsp;
<span style="color: #adadad; font-style: italic;"># This is the whitelisting of the ajax handler</span>
&lt;<span style="color: #000000; font-weight:bold;">Files</span> admin-ajax.php&gt;
    <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
    <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
    <span style="color: #00007f;">Satisfy</span> any 
&lt;/<span style="color: #000000; font-weight:bold;">Files</span>&gt;</pre></div></div>

<p>Please notice that you absolutely need to create the <tt>htpasswd</tt> file, see the linked tutorial above.</p>
<p>Here&#8217;s the necessary configuration to whitelist a file in a password protected location in lighttpd:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;url&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=~</span> <span style="color: #ff0000;">&quot;^<span style="color: #000099; font-weight: bold;">\/</span>wp-admin<span style="color: #000099; font-weight: bold;">\/</span>.*&quot;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #0000ff;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;url&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!~</span> <span style="color: #ff0000;">&quot;^<span style="color: #000099; font-weight: bold;">\/</span>wp-admin<span style="color: #000099; font-weight: bold;">\/</span>admin-ajax<span style="color: #000099; font-weight: bold;">\.</span>php&quot;</span> <span style="color: #009900;">&#123;</span>
        auth<span style="color: #339933;">.</span><span style="color: #000066;">require</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
            <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>
                <span style="color: #ff0000;">&quot;method&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;basic&quot;</span><span style="color: #339933;">,</span>
                <span style="color: #ff0000;">&quot;realm&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;Password protected area&quot;</span><span style="color: #339933;">,</span>
                <span style="color: #ff0000;">&quot;require&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;user=theuser&quot;</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2010/06/14/htaccess-protect-wordpress-admin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirecting all subdomains to the main domain</title>
		<link>http://www.nkuttler.de/2009/01/11/redirecting-all-subdomains-to-the-main-domain/</link>
		<comments>http://www.nkuttler.de/2009/01/11/redirecting-all-subdomains-to-the-main-domain/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 14:29:30 +0000</pubDate>
		<dc:creator>nicolas</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[duplicate content]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[virtual hosts]]></category>

		<guid isPermaLink="false">http://www.nkuttler.de//?p=313</guid>
		<description><![CDATA[How to redirect a subdomain to the main domain, or a domain to a subdomain. Redirect domain.com to www.domain.com.]]></description>
			<content:encoded><![CDATA[<p>Using the canonical hostname for websites isn&#8217;t an obvious problem. After all, who really cares if your site is accessible at <tt>www.domain.com</tt> and <tt>domain.com</tt>? Search engines, for example, could penalize you for having the same content on both domains. I think that today they are smart enough to discover this specific case though.<span id="more-313"></span></p>
<p>Another problem can happen when you use cookies. If not done correctly, your user&#8217;s cookie won&#8217;t be available to the website when they were stored under <tt>www.domain.com</tt> and he uses <tt>domain.com</tt> the next time he visits. See the <a href="http://cgi.netscape.com/newsref/std/cookie_spec.html">cookie specs</a> for more details.</p>
<p>A quick research led me to a solution for apache that I didn&#8217;t like too much. It involves using <tt>mod_rewrite</tt>. <tt>mod_rewrite</tt> is a great tool, but there&#8217;s a better solution for redirecting to your main domain from subdomains or second level domains. Simply use a catchall virtual host in your apache host configuration file(s) to do the redirects. This will solve all the SEO, caching and cookie issues, and it will save some CPU cycles compared to the <tt>mod_rewrite</tt> or higher level solutions.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #adadad; font-style: italic;"># NameVirtualHost *:80</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> www.domain.com
    <span style="color: #adadad; font-style: italic;"># This is your main domain</span>
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> domain.com
    <span style="color: #00007f;">ServerAlias</span> *.domain.com
    <span style="color: #adadad; font-style: italic;"># This is to make sure that foo.domain.com gets redirected too</span>
    <span style="color: #adadad; font-style: italic;"># If you want to use more virtual hosts on subdomains,</span>
    <span style="color: #adadad; font-style: italic;"># just define them earlier</span>
    <span style="color: #00007f;">Redirect</span> / http://www.domain.com/
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>Please refer to the <a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect">mod alias docs</a> to decide which <tt>Redirect</tt> you need, this example uses a 302.</p>
<p>For lighttpd you can use this:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=~</span> <span style="color: #ff0000;">&quot;domain<span style="color: #000099; font-weight: bold;">\.</span>com&quot;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #0000ff;">$HTTP</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #ff0000;">&quot;www.domain.com&quot;</span> <span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">.</span>redirect <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
            <span style="color: #ff0000;">&quot;^(.*)$&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;http://www.domain.com$1&quot;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>By the way, if you&#8217;re an <tt>IIS</tt> user, you might want to read <a href="http://www.xoc.net/works/tips/domain.asp">this</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nkuttler.de/2009/01/11/redirecting-all-subdomains-to-the-main-domain/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
