301 and 302 Redirects (e.g. SEO Optimization) Print

  • 0

Here are the steps for making a 301 or 302 redirect users from one domain to another. It is often used for Search Engine Optimization Reasons. For Linux hosting plans, you do this by creating an .HTACCESS file in the root of your website. On Windows, you will use the native Web.config file for 301 and 302 redirects using Microsoft's IIS syntax. 

WARNING: It is COMPLETELY possible to accidentally block all visitors to your website or get banned from a search engine. Again, we do not suggest using this tag without having conducted ample research. If you are unable to follow the directions below, it is likely you do not have the expertise to implement this tag. 

Linux Plans:

  1. Create a text file called .HTACCESS and upload it into your website's root directory. e.g. wwwroot or public_HTML
  2. Add the following to the top of the file:  
    RewriteEngine On
    RewriteBase /
  3. Follow some of the options below to write a rule to make your redirect.

Here are samples rules you may need:

  1. The first redirects visitors who do not type in WWW when requesting your domain name e.g. http://ephost.com to the same domain but WITH the WWW in front. e.g. http://www.ephost.com.
    RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
    RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
  2. The second rule is the opposite of the one above and forces WWW to your apex domain (no www).
    RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
    RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
  3. This redirects visitors looking for a specific web page to another web page.

    RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
    RewriteRule ^images/your-old-logo-\.gif$ http://yoursite.com/images/your-new-logo.png$1 [R=301,L]

 Best of luck with your SEO endeavors.

 

Windows Accounts:

301/302 Redirects can be created by editing the web.config file in the root of your website (httpdocs folder):

  1. Navigate to the httpdocs directory
  2. Open the web.config file.
  3. Copy the following lines into the web.config file. It is important to place these between the <system.webServer> blocks.

Here are samples rules you may need:

1. The example redirects users from no SSL to SSL / HTTP to HTTPS

<system.webServer>
    <rewrite>
        <rules>
            <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

2. This example redirects users from no WWW to WWW.

<system.webServer>
  <rewrite>
    <rules>
      <rule name="No WWW to WWW" stopProcessing="true">
        <match url=".*" ignoreCase="true" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="^ephost\.com$" />
        </conditions>
        <action type="Redirect" redirectType="Permanent" url="https://www.ephost.com/{R:0}" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

3. Redirect visitors from one page to another page.

<system.webServer>
  <rewrite>
    <rules>
      <rule name="RedirectToNewPage" stopProcessing="true">
        <match url="^oldpage\.aspx$" />
        <action type="Redirect" url="/newpage.aspx" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

4. Here is an alternate method redirecting visitors from one page to another page.

<system.webServer>
  <httpRedirect enabled="true" destination="/newpage.aspx" httpResponseStatus="Found" />
</system.webServer>

 


Also See
: Website Features KB's Domain/DNS KB'sHOW TO KB'sEmail Settings POP3 / IMAP | Check email online | Email Troubleshooting | Adding an email to your hosting account WINDOWS / LINUX

Contact Support

If you are still having issues, please contact us for further help.
1-877-EPHOST1 | support@ephost.com

 

 


Was this answer helpful?

« Back