A more detailed method for solving the problem of Win2003 IIS6.0 301 redirect with parameters _win Server

Source: Internet
Author: User
Tags file url parent directory microsoft iis microsoft website

The website replaces the domain name, uses the old domain name 301 to refer to the new domain name.

Setting the URL permanently from IIS can be, it looks easy, and it takes a while to discover that the parameters are not on.

From the Microsoft website to find the following instructions, sure enough:
IIS 301 Redirection Settings
It is more convenient to use this time to set IIS redirection. Here is the IIS redirection method, because the site revision is directory-oriented migration, so have to understand the following several Microsoft IIS directional parameters:
We are in the setting of URL redirection can be used with the Parameter form URL, because after all, often face the URL is a lot, if so one or two pages 301 redirect casually how the whole can be.
Parameter 1: $S--passes the suffix of the URL to the new URL;
Parameter 2: $P--Pass the query parameter in the URL to the new URL, excluding the question mark (?)
Parameter 3: $Q--Pass the query parameter in the URL to the new URL, including the question mark (?), so when you set the URL address, do not follow the question mark, for example:
Http://www.jb51.net/catalog.asp?cate=os&page=1, redirect to Http://www.jb51.net/category.php?cate=1&page=1
You only need to set the catelog.asp file settings redirect to Category.php$q in IIS.
Parameter 4: $V-passes the requested URL, but does not include the server name and any parameters.
There is also the use of wildcard redirection, this is not commonly used for temporary not explained.
Because we redirect multiple directories, it's very cumbersome to set up different directional files individually, but if all are directed to a file and then redirected, the result is null because $_server[' http_referer ' is unable to go through the corresponding reference page. So have to use the above parameters to pass, this time only need to add a parameter to solve the problem of the transfer of reference pages, such as/301.php?go= $V, so you can directly in the php file URL 301 redirect Jump processing.

REDIRECT Reference (IIS 6.0)

Redirecting a client request is a way to ensure that the user gets the correct page, which applies to situations where the site is under construction or has changed identities. You can redirect a client request to a directory on the same WEB server, or redirect to another URL.

Configure URL and wildcard redirection
You can configure redirection to URLs and wildcard redirection programmatically. You can use redirect variables and flags to specify targets and behaviors by changing the HttpRedirect metabase properties.

The following example shows the format of a simple redirection string.

Http://destinationurl[,flag[s]]

Where destinationurl can include the following redirection variables to pass the relevant portions of the initial URL to the destination URL. You can use multiple variables in a single redirection string.

Variable Describe Example

$S

Passes the suffix of the requested URL to the new URL. The suffix is the part of the initial URL that is reserved after the redirected URL is substituted.

If the exact_destination flag is not set, the name of the resulting destination URL will have the name of the requested file (as the folder name) and the file name itself.

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

The configuration redirects to the following exact URL:

Http://fabrikam/newscripts$s

A new request for the following URL:

Http://fabrikam/Scripts/Program.exe

Automatically redirects to the following URL:

Http://fabrikam/NewScripts/Program.exe

$P

Passes the parameters in the initial URL, such as the QueryString parameter, to the new URL, excluding the question mark (?).

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

Configure redirects to the following URL:

Http://fabrikam/newscripts$p

A new request for the following URL:

Http://fabrikam/Scripts/File.asp?var1=5&var2=6

Automatically redirects to the following URL:

Http://fabrikam/NewScriptsvar1=5&var2=6

$Q

Passes the parameters in the initial URL, such as the QueryString parameter, to the new URL, including the question mark (?).

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

The configuration redirects to the following exact URL:

Http://fabrikam/newscripts$s$q

A new request for the following URL:

Http://fabrikam/Scripts/File.asp?var1=5&var2=6

Automatically redirects to the following URL:

Http://fabrikam/NewScripts/File.asp?var1=5&var2=6

$V

The URL that passes the request, excluding the server name and any parameters. To include parameters, you can use $P or $Q variables and $V variables.

If the exact_destination flag is not set, the name of the resulting destination URL will have the name of the requested file (as the folder name) and the file name itself.

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

The configuration redirects to the following exact URL:

Http://contoso$v

A new request for the following URL:

Http://fabrikam/Scripts/File.asp

Automatically redirects to the following URL:

Http://contoso/Scripts/File.asp

Using wildcard redirection
You can use the redirect wildcard character to match any number of characters in the original URL. The destination URL is marked with an asterisk (*) and a semicolon (;) Begins with a semicolon-delimited wildcard character and a target URL. The following example shows a format for a redirected string that uses a wildcard character.

*; Wildcard1; destination1[; Wildcard2; destination2][, Flags]

The Wildcardn can include an asterisk (*) to match any number of characters in the initial URL and pass these characters to destinationn using the variables defined in the following table ($ to $).

Variable Describe Example
$ to $

Passes the part of the requested URL that matches the specified wildcard character. For each wildcard;destination set, the wildcard character must start with the $ $. The redirection string must attach a exact_destination flag.

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

Configure using the following redirection string:

*; /scripts/*_in.asp; /newscripts/$0.dll; /scripts/*_out.asp; Http://contoso/newscripts/$0.dll

A new request for the following URL:

Http://fabrikam/Scripts/data_in.asp

Http://fabrikam/Scripts/data_out.asp

Automatically redirects to the following URLs, respectively:

Http://fabrikam/NewScripts/data.dll

Http://contoso/NewScripts/data.dll

!

Redirection is not allowed.

You can use this variable if you want the file or subdirectory to not be redirected when the parent directory is configured for redirection.

If you map to a virtual directory for the following Web sites:

Http://fabrikam/Scripts

Configure to redirect to a location other than the following Web sites:

Http://fabrikam/Scripts/Commerce/Accounts

You must exempt the redirection by programmatically setting the redirected string of the Exempt folder to:

*;!

For example, to redirect all requests for/scripts/filename.stm to a file named Default.stm and redirect all requests to/scripts/filename.htm to the Default.htm file,/scripts The virtual directory uses the following redirection request:

*; Filename.stm;/default.stm/filename.htm;/default.htm

Using redirection Flags
The following flags are used to extend the redirection string for a URL or wildcard format. Multiple flags are allowed. Flags are attached programmatically to the redirected string in HttpRedirect, or configured by selecting the checkbox in IIS Manager.

Sign User interface check box Describe
Exact_destination

The exact URL entered above

The value that is provided for destination should be considered an absolute target location.

Child_only

The directory below the directory

Notifies IIS that only one redirection should occur because the target location is a subdirectory of the initial URL. This flag avoids loops. Also, this flag instructs IIS to redirect the request only if the request is a subfolder or file that is redirected to the initial URL.

Permanent

Permanent redirection of resources Indicates that the resource is permanently redirected.

Temporary

Clear the Permanent redirect for resources check box Indicates that the resource is temporarily redirected.

Overview: Achieve the overall 301 jump of the site, set the IIS site properties home directory redirect to URL write http://www.newdomain.com$s$q and select The exact URL and the permanent redirection of the resource entered above. The URL parameters of the old domain name can be passed to the new domain name completely.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.