Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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]
</IfModule>
# END WordPress

What happens is that people get redirected to http://domain.com/subdir, while I want them to end up at http://www.domain.com/subdir. I tested with curl and noticed that it redirects with these steps:

  1. domain.com => www.domain.com
  2. www.domain.com => www.domain.com/subdir
  3. www.domain.com/subdir => domain.com/subdir

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
add comment

1 Answer 1

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 www.domain.com/subdir

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

Your Answer

 
discard

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.