Error with htaccess Sem redirect to WWW

Asked

Viewed 356 times

0

I have the following code in my htaccess which redirects the user if they access the site without www, it works perfectly if you type in the direct domain without www it will redirect, but from facebook it does not redirect.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{HTTP_HOST} ^bluanime.com [NC]
    RewriteRule ^(.*)$ http://www.bluanime.com/$1 [L,R=301]
</IfModule>

The way you’re typing bluanime.com in the browser’s address bar, it is redirected to the version www.bluanime.com, but on facebook in case I put in the description only bluanime.com and the person click it is not redirected, which may be causing this?

This is the link that should make the automatic redirect on facebook Link to the redirect, up to here in the stack it is not redirected to the www version

  • 1

    The facebook get the data and generates content in the box, but this does not seem to me a failure of the . htaccess and yes how facebook works, IE the box has nothing to do with redirect, if the person click the link then when entering your site redirecting occurs, but it does not mean that facebook will format the link for you.

  • @Guilhermenascimento I edited the question and put the link whose redirection should happen, until here in the stack when you click it is not redirected

  • Here is the link to the post https://www.facebook.com/lparadoxu/posts/1911530899082005

  • Here if I type the link directly into the bar without www, it does the redirect, which is wrong then?

1 answer

0


It must be the cache of your browser that kept redirecting something, I think, or yours. htaccess is not in the folder or another fault, in case this is not necessary:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Do so:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^bluanime.com [NC]
RewriteRule ^(.*)$ http://www.bluanime.com/$1 [L,R=301]

If you fail do so (this form actually I think is better because it will be easier to port if the domain changes or uses multiple domains):

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  • It seems that now worked and the link on facebook ta redirecting, both here and on facebook, what is the importance of the two lines that you asked me to remove in this case?

  • 1

    Two lines denied redirecting if the file or folder existed. @Leoletto

Browser other questions tagged

You are not signed in. Login or sign up in order to post.