ip6tables and automatic IPV6 addressing

Over the weekend, I switched VPS providers from Slicehost to Linode. I requested an IPV6 address for my server (and got one within 2 minutes of my ticket!) and this morning sat down to set up some firewall rules. After setting up the rules, however, I found that the IPV6 address was no longer being assigned manually. After determining it was due to ip6tables, I looked around and found I needed the following rules:

-A INPUT -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT
-A INPUT -p icmpv6 --icmpv6-type router-solicitation -j ACCEPT
-A INPUT -p icmpv6 --icmpv6-type neighbour-advertisement -j ACCEPT
-A INPUT -p icmpv6 --icmpv6-type neighbour-solicitation -j ACCEPT
-A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT
-A INPUT -p icmpv6 --icmpv6-type echo-reply -j ACCEPT

After adding the above rules, my network adapter was happily assigned an IPV6 address.

Force WordPress to perform a direct upgrade

After modifying my server configuration over the weekend, I realized that WordPress would no longer upgrade automatically, and was asking for FTP information to perform the upgrade. The only problem with this is that I do not have standard FTP access – it’s all SFTP.

I verified the permission set, and the www-data group has write permissions as necessary. However, apparently WordPress looks to the user permissions, and not group. So I was stuck – I’m not going to elevate user permissions to have full access. I did some searching and found the following directive that can be placed in the wp-config.php file:


After adding this option, the upgrade went through fine. Success.

Canonical redirect with Apache 2

Yesterday, I wrote on how to configure a canonical redirect in IIS 7.  Today, we’re going to look at how to do the same in Apache2.

What is a canonical redirect?  Most sites are configured (or should be, at least) to serve content to requests for both www and non-www versions of the site (www.example.com and example.com).  Basically, when we have 2 or more domain names being served the same content, we want to ensure that precautions are taken to preserve search engine rankings.  If a search engine sees multiple sites with the exact same content, it is likely to rank those sites lower.  Therefore, we want to ensure that the search engine knows that they are both the same site – and we can do this with a canonical redirect.  The most common canonical redirects send requests from www to non-www, or vice versa.  A canonical redirect issues a 301 moved permanently response to the client accessing the site, which tells search engines when they crawl to only index the content at the source of the redirect.

Here’s how to set up this redirect in Apache.

First, we need to ensure that Apache’s rewrite is enabled:

sudo a2enmod rewrite

Then, in the site configuration file, we need to add the following:

ServerName example.com
ServerAlias www.example.com

The two lines above ensure that Apache will respond to requests for both domains.  We then need to add the following to redirect all requests to the www version of the site:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.test\.net [NC]
RewriteRule ^(.*)$ http://www.test.net$1 [L,R=301]

If you want to redirect all requests to the non-www version of the site, it would look like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^test\.net [NC]
RewriteRule ^(.*)$ http://www.test.net$1 [L,R=301]

Save the file, and reload your Apache settings:

sudo /etc/init.d/apache2 reload

Your redirects should now be working correctly.

Redirecting canonical names in IIS 7

Preface:  This procedure uses the domain example.com for illustrative purposes only.  You will want to substitute example.com for your own domain.  Also, if the images are too small, click on them to expand to full size.

When building a website, it is essential to plan for users that may try to access your site using www and non-www versions of your domain (www.example.com and example.com).  It is possible to just simply configure DNS to point both records to the same server and do nothing more, however this is not best practice.  Search engines that crawl your site will see two seperate sites with the exact same content, which can jeopardize your rankings.  Instead, we should be informing search bots to index the content at only one canonical URL.  We can accomplish this using a 301 redirect – this informs the bot that the URL to redirect from has permanently moved to the URL you are redirecting to (example: www.example.com to example.com)  This has the benefit of not only streamlining future indexes, but also informing search engines to change URLs for already indexed content to the new URL.

So how do we configure IIS to redirect traffic?

First, we need to ensure the IIS URL Rewrite Module 2.0 is installed from the IIS Website.

Next, ensure that we have both canonical names configured on the same web site in IIS by right clicking on the site and selecting “Edit Bindings”:


You should see a list of your canonical URLs: If the URLs are not all present, click the add button to add a binding.  Type the domain name in the Host Name field, and click OK.  Repeat this step until all canonical names are configured, then click Close:


We then want to access the URL Rewrites plugin in the site dashboard.  Select Add Rule:


Scroll down in the window of available options, and select Canonical domain name.


If you want the www to always appear in the URL, select www.example.com.  If you do not want www in the URL, select example.com.


Click ok, and you will see the CanonicalHostName1 rule created.  Double click if you would like to view the parameters.


To test, open your web browser.  If you used www.example.com as your main URL, type example.com in the address bar and hit enter.  You should see the URL change to www.example.com.  If you used example.com as the main URL, typing www.example.com and pressing enter should change the URL to example.org.  If you use a tool such as Fiddler or Firebug, you’ll see the 301 Moved Permanently response, followed by a request for the main URL.

You have now successfully configured a canonical redirect.  Congrats!

Related Posts: Canonical Redirect with Apache 2

Configure WordPress to ping Feedburner automatically

By default, FeedBurner will check your RSS feeds every half hour.  Depending on the content of your site, however, you may want your RSS feed to be updated instantly.  FeedBurner allows you to visit a page to re-ping your feed and update, and you can use this feature to have your feed updated automatically.

All you have to do is place the following URL in Settings -> Writing -> Update Services:

http://feedburner.google.com/fb/a/pingSubmit?bloglink=http://www.domain.com   (be sure to update “www.domain.com” with your site’s URL)

Save the settings, and now WordPress will automatically send a notification to Feedburner when you publish a new post, which will instantly update your RSS feed.