WWW to NON-WWW redirect adding "?rewrite=1" to URL

    • 45 posts
    January 21, 2019 8:55 PM EST

    Hi,

    I am trying to setup www to non-www redirect. The problem I'm having is that once redirected, "?rewrite=1" is added to the end of URL.

    I would like redirect to work without changing URL as I notice search engines are indexing some pages with "?rewrite=1".

    I'm using this in .htaccess:

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

    I have also tried this in virtual hosts file and have same results:

    <If "%{HTTP_HOST} != 'website.com'"> Redirect 301 / https://website.com </If>

    I know this is something related to SE PHP as I have tried this on my other websites and not experiencing same issue.

    Anyone know how to to get this to work properly?


    This post was edited by Stepan at January 21, 2019 8:57 PM EST
    • 45 posts
    January 21, 2019 10:53 PM EST

    Hm, this can probably be deleted.

    Browser cache and because I was doing permanent redirect messed me up.

    • Moderator
    • 6923 posts
    January 22, 2019 5:13 AM EST

    Do you mind if I keep it? It could help other clients.