System Status
Buy Now
  • Email & Apps
  • Office 365
Login
  • MyRackspace Portal
  • Cloud Control Panel
  • Rackspace Webmail Login
  • Cloud Office Control Panel
  • Support Home
  • How-To
  • Developer Documentation
  •  Blogs 
    • Expert Insights Tech Blog
    • Rackspace Blog
    • Solve: Thought Leadership

Support Network

End-to-End Multicloud Solutions.   Solving Together.â„¢   Learn more at Rackspace.com

How–To Home

Cloud Servers

  • Introduction
  • FAQ
  • All Articles

Creating Apache redirects

Last updated on:  2020-06-17

Authored by:  Matthew Brown


This article explains redirects in Apache® and how to set them up.

What is a redirect?

Apache can create a redirect that points from one vhost to another vhost on the server or another external site. Common reasons for using this feature are to force http traffic to https and to move domain names.

Using the redirect directive

Apache has a redirect directive that you can add to the vhost to redirect any traffic to the specified site. Below is an example of using the directive to redirect all http traffic to https:

    `<VirtualHost *:80>
        DocumentRoot /var/www/example.com/httpdocs
        ServerName example.com
        Redirect / https://example.com      <-----
        ServerAlias www.example.com
    </VirtualHost>

      <VirtualHost *:443>
         DocumentRoot /var/www/example.com/httpdocs
         ServerName example.com
         ServerAlias www.example.com
          SSLEngine on
          SSLCertificateFile /etc/pki/tls/certs/2017-example.com.crt
          SSLCACertificateFile /etc/pki/tls/certs/CABundle.crt
          SSLCertificateKeyFile /etc/pki/tls/private/2017-example.com.key
       </VirtualHost>`

The preceding example only works for that single page by establishing a temporary 302 redirect. Establish a permanent 301 redirect, by using the redirect directive as follows:

    Redirect 301 / https://example.com
    Redirect permanent / https://example.com

Share this information:

©2020 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER

About Rackspace
  • About
  • Customer Stories
  • Events
  • Programs
Blogs
  • The Rackspace Blog
  • Expert Insights Tech Blog
  • Solve: Thought Leadership
  • News
  • Contact Information
  • Legal
  • Careers
Site Information
  • Style Guide for Technical Content
  • Trademarks
  • Privacy Statement
  • Website Terms
Support Network
  • Support Network Home
  • Rackspace How-To
  • API Documentation
  • Developer Center
  • ©2020 Rackspace US, Inc.