开发者

How do I redirect example.com to example.com/subdirectory?

I’m trying to redirect example.com (and example.com/, www.example.com and www.example.com/) to example.com/sub开发者_如何学Cdirectory. I could do this easily using HTML but from what I read, it’s better to make a 301 redirect using Apache.

How can I do this using Apache?


If you want 301 redirect:

RedirectMatch 301 ^/$ /subdirectory/


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜