Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my root domain I have an .htaccess to redirect non-www to the www, and to redirect to a subdirectory (containing a temporary website). This is done using the following code:

Options +FollowSymLinks
RewriteEngine On

# non-www to www, exclude localhost
RewriteCond %{HTTP_HOST} \.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# temp redir to subdir-wordpress
RewriteRule ^$ /subdir [L]

In the subdirectory runs a Wordpress setup using the following .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]
# END WordPress

What happens is that people get redirected to, while I want them to end up at I tested with curl and noticed that it redirects with these steps:

  1. =>
  2. =>
  3. =>

So the .htaccess in the root dir seems to work fine. But the automated Wordpress .htaccess seems to destroy my hard work :-)

Anyone knows how I can modify the Wordpress .htaccess so it does work?

share|improve this question
up vote 2 down vote accepted

Its not the Wordpress .htaccess but the Wordpress blog url.

Log into your Wordpress Admin and then goto Settings->General and change your Wordpress URL to

share|improve this answer
This might indeed be the case – Not Available Jun 10 '11 at 17:19
Thanks! Changing this solved the troublesome redirect indeed. – Lode Jun 12 '11 at 14:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.