tags:

views:

27

answers:

3

Hey, I’m trying to redirect example.com (and example.com/, www.example.com and www.example.com/) to example.com/subdirectory. I could do this easily using HTML but from what I read, it’s better to make a 301 redirect using Apache. However, I’m having a hard time finding documentation on how to do this.

+1  A: 

You should use a .htaccess file using the RewriteRule keyword. See Apache docs for more info on how to do this.

CFP
+1  A: 

If you want 301 redirect:

RedirectMatch 301 ^/$ /subdirectory/
unbeli
Thanks, this works like a dream!
Frode
A: 
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

Source: http://www.webconfs.com/how-to-redirect-a-webpage.php

Example usage would be

RewriteRule ^/$ http://somewhere.com/directory [R=301,L]

I guess

Robus