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

I've got a domain name,, which I've linked to using this .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ blog [L]

Now when I go to, I'm redirected to Is it possible to write a .htaccess rule so that I can avoid the subdirectory name appearing in the new address?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Try this one

RewriteRule ^(.*)$ /blog/$1 [L]

I would suggest you to create a virtual host for and point the document root to /blog/ directory

share|improve this answer
It's giving me a 500 error. I'm no good at .htaccess syntax so I can't tell what's going wrong. In what way does a virtual host help? Less for Apache to sort through? – lowercasename Oct 24 '12 at 6:00
What is your operating system/web server? – Hex Oct 24 '12 at 6:02
Heh... I'm using Apache2 on a Raspberry Pi, Raspbian OS. So for all intents and purposes it's Debian, just with an ARM processor. It's a toy server, of course, but it's had no hiccups yet. – lowercasename Oct 24 '12 at 6:04
Bam. Adding this line after the RewriteRule fixed it: RewriteCond %{REQUEST_URI} !^/blog Which is odd - I don't know why it was still trying to redirect into the subdirectory, I was forcing it to go from Anyway, that's sorted. Thank you! – lowercasename Oct 24 '12 at 6:19
Im happy it worked for you :) – Hex Oct 24 '12 at 12:03

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.