Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect entire site to facebook page

how to

         

christian2

6:24 am on Dec 13, 2014 (gmt 0)

10+ Year Member



Ok yes, hope is not one of the other how to 301 redirect thread.
So, basically I want to redirect via htaccess entire domain (www and not www) including inner pages to a facebook page.

I tried with this code

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

where example.com = www.facebook.com/my.personal.page

However it only redirect the root domain without the inner pages.

How can I redirect entire domain to my facebook page?

Thanks

[edited by: phranque at 12:13 pm (utc) on Dec 13, 2014]
[edit reason] exemplified domain [/edit]

lucy24

9:19 pm on Dec 13, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How can I redirect entire domain to my facebook page?

By redirecting your entire domain to your facebook page. Currently you're redirecting

example.com/ >> facebookpage
example.com/pagename.html >> facebookpage/pagename.html
example.com/directory/otherpage.html >> facebookpage/directory/pagename.html

which can't possibly be the way facebook URLs work.

:: carefully turning my back on the "Are you out of your cotton pickin' mind?!" aspect of the question ::

christian2

6:13 am on Dec 14, 2014 (gmt 0)

10+ Year Member



So, I guess is no way to redirect sub pages as well?

lucy24

8:48 am on Dec 14, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can easily redirect everything to a single page. But if you really wanted to do this
:: suppressing editorial comment ::
you should constrain the redirect to page requests. Use a formulation something like

RewriteRule (^|/|\.html)$ http://example.com/redirect-target-here [R=301,L]


replacing ".html" with whatever extension your site actually uses. Or formerly used. Note that the parentheses are just for grouping; you're not capturing anything for reuse.

The purpose of this is to avoid redirecting requests for non-page files such as images and stylesheets. And you certainly don't want to redirect requests for robots.txt or sitemap.xml. (Query: Who would request supporting files if you've already redirected the pages? Answer: Search engines.)

Once you've done this, requests for non-page files-- .css, .jpg, .js and so on-- should instead get a 410.

If you have any existing RewriteRules that end in [F], keep them.