Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter rajatady

    (@rajatady)

    You could add this to your .htaccess file

    RewriteCond %{HTTP_HOST} !^www\.shoppingredux\.com$ [NC]
    RewriteRule ^(.*)$ https://www.shoppingredux.com/$1 [R=301,L]
    Thread Starter rajatady

    (@rajatady)

    Where exactly should I write it. I am very new to wordpress and literally know nothing about coding. Please tell me detail.

    If you already have an .htaccess file in the root folder of your wordpress installation, save a backup copy so you can restore it if something goes wrong.

    Add the following at the beginning of the file:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.shoppingredux\.com$ [NC]
    RewriteRule ^(.*)$ https://www.shoppingredux.com/$1 [R=301,L]

    Save the file and test to see if the site displays correctly. If you get an error restore the backup.

    Thread Starter rajatady

    (@rajatady)

    I cannot find the .htaccess file in the root folder.

    It appears that you are on a windows server, .htaccess will not work there.
    Try this:
    301 Redirects & Canonical Redirects:
    Microsoft IIS Web Servers

    To Perform this you need administrative access to the IIS Server Application. If you do not have this then you can do the redirects in ASP or PHP.

    PHP Canonical Redirect:
    (non-www to www)

    <?php
    if (substr($_SERVER[‘HTTP_HOST’],0,3) != ‘www’) {
    header(‘HTTP/1.1 301 Moved Permanently’);
    header(‘Location: https://www.&#8217;.$_SERVER[‘HTTP_HOST’]
    .$_SERVER[‘REQUEST_URI’]);
    }
    ?>

    Thread Starter rajatady

    (@rajatady)

    Please explain the above process in detail. I am quite new to these things. Also, it will be quite helpful if you tell me that which type of hosting is the best. I am currently on a windows server as you correctly pointed out. If you provide a better option, I will upgrade my hosting next month.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Cannot redirect my website from site.com to www.site.com.’ is closed to new replies.