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.

Apache2
Plesk 9.x

I have a website www.example.com
and my blog is on www.example.com/blog

I have no content on www.example.com as of now
So I want all requests for example.com to be redirected to www.example.com/blog

How should I do that ? Is this something I can do in Apache?

I am using the GoDaddy DNS server.
Not sure if it matters- but I have multiple domains hosted n the same server. And I am using Plesk to manage my virtual hosts.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Create a .htaccess file in your DocumentRoot and add these lines:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^$ /blog [R=301,L]
</IfModule>

To answer your question about DNS settings, no, those don't matter. DNS is only concerned with the "domain" portion of the URL, not what follows it in the url path.

share|improve this answer
    
You just created an infinite redirect loop, he wants to redirect to the same domain. –  PowerSp00n Apr 20 '10 at 20:28
    
You're right. Edited my answer accordingly. –  EEAA Apr 20 '10 at 20:33
    
Worked like a charm ! Thanks ! –  RN. Apr 21 '10 at 15:12

The easiest solution is by creating an index.php file in your DocumentRoot with the following content:

<?php
header("Location: www.example.com/blog/"); 
?>
share|improve this answer
1  
Why bring php into the equation when you can do it with apache alone? –  EEAA Apr 20 '10 at 20:23

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.