How Do I Redirect Web Pages?
Scenarios
You can refer to the procedure below to do a 301 redirect.
Procedure
- Launch a website, for example, www.aaa.com, in the IIS.
- Create an empty folder on the disk.
- Create a website, for example, aaa.com, in the IIS and point it to the empty folder.
- On the home page, select HTTP Redirection and set parameters as follows:
- Select Redirect requests to this destination.
- Enter www.aaa.com$S$Q in the text box.
The purpose of adding $S$Q to the end of a URL is to support redirection for a URL containing question marks (?).
- Select Redirect all requests to exact destination (instead of relative to destination).
- Set Status code to Permanent (301).
Figure 1 HTTP Redirect
Helpful Links
In addition to redirection in the IIS, you can perform 301 redirects through code. The following describes how to perform 301 redirects in PHP and Apache.
- 301 redirect in PHP
<?php Header("HTTP/1.1 301 Moved Permanently"); Header("Location: http//www.***.cn"); //Redirect to a URL with www. ?>
- 301 redirect in Apache
Example code for redirecting your domain to a www URL:
deny from all RewriteEngine on RewriteCond %{HTTP_HOST}^(****\.com)(:80)?[NC] RewriteRule ^(.*) http://www.****.com/$1[R=301,L] order deny,allow
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.