0

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.

2 Answers 2

2

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.

2
  • You just created an infinite redirect loop, he wants to redirect to the same domain.
    – PowerSp00n
    Apr 20, 2010 at 20:28
  • You're right. Edited my answer accordingly.
    – EEAA
    Apr 20, 2010 at 20:33
0

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

<?php
header("Location: www.example.com/blog/"); 
?>
1
  • 1
    Why bring php into the equation when you can do it with apache alone?
    – EEAA
    Apr 20, 2010 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .