3 WordPress htaccess Tips


Jan
29
2010

Wordpress logo WordPress is a powerful blogging/CMS platform that enables a variety of different Internet users to create and publish content with ease. The following tips will enable you to improve your WordPress blog even further.

Permalinks for SEO

This is something I try to do straight away when setting up a new WordPress blog. The exact settings depend very much on how you want to display your content (if you want to display the category or the date in the URL). By default WordPress doesn’t use the optimal URL structure for SEO, so making this change early-on saves time with redirects later on.

However, keeping folder levels to a minimum makes sense and in the past Yahoo adviced limiting URL folder depth, it also makes URLs more memorable for users. An interesting SEO study was carried out on Google, Yahoo and Live’s (now Bing) indexing of pages up to 10 folders deep: Do Deep Folders Stop Search Engines which showed Google and Yahoo had no trouble, but Bing did have issues at the time (which may still be the case).

To make this change you need to access the WordPress admin panel and make an adjustment to the Settings > Permalinks page. You’ll see from the example image below, that I simply use %postname% for my URL structure. WordPress will automatically update your .htaccess file in the blog root if you have permissions set t allow this, otherwise you are presented with a cut and paste .htaccess file at the bottom of the Permalinks page which you can simply save and upload to your blog root folder.

Permalinks

The .htaccess file should look something like this, notice in this case the blog is stored in the folder /blog/ rather than at the root of the site. WordPress will automatically generate the correct .htaccess settings for your WordPress setup.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

Secure Admin Area

This tip comes with a caveat—if you access and publish content from only a couple of locations, I.e. your home or office and these locations use a dedicated IP address then this tip is worth implementing for increased security. However, if you create content at many locations, I.e. Airport lounge, Internet cafĂ© then avoid using this tip.

Basically you will lock access to your WordPress admin area by blocking all IP addresses except the ones that you specify in your .htaccess file. This .htaccess file should be saved in the wp-admin folder rather than the blog root folder. Example below:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Access Control"
AuthType Basic
order deny,allow
deny from all
# Allow from Office A
allow from xy.xy.xyz.xyz
# Allow from Office B
allow from xyz.xyz.xyz.x
# Allow from Home
allow from xy.xyz.xyz.xyz

You will need to change the ‘xyz’s to match the IP addresses for the different locations that you want to grant access to the admin panel. If you’re unsure what your IP address is you can use a tool like this.

Easy Admin Access

If like me you don’t have an admin link on your blog sidebar, you will have to navigate to the admin panel by typing the URL into your browser address bar. To save some time, I setup a redirect within the root .htaccess file to take me to the admin control panel. It looks like this:

Redirect 301 /admin http://brightscape.net/blog/wp-admin/
Redirect 301 /admin/ http://brightscape.net/blog/wp-admin/

Now after typing the domain, I just type /admin or /admin/ and it will automatically redirect me to the admin control panel.

  • Digg
  • Sphinn
  • Propeller
  • StumbleUpon
  • Twitter
  • del.icio.us
  • Facebook
  • FriendFeed

Related Posts



Leave a Reply