Hey, I’m attempting to redirect example.com (and example.com/, www.example.com and www.example.com/) to example.com/subdirectory. I possibly could do that easily using HTML but from things i read, it’s better to create a 301 redirect using Apache. However, I’m getting a difficult time finding documentation regarding how to do that.
You need to use b .htaccess file while using
RewriteRule keyword. See Apache docs for more information regarding how to do that.
If you would like 301 redirect:
RedirectMatch 301 ^/$ /subdirectory/
Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Note* This .htaccess approach to redirection works ONLY on Linux servers getting the Apache Mod-Rewrite moduled enabled.
Example usage could be
RewriteRule ^/$ http://somewhere.com/directory [R=301,L]