SoFunction
Updated on 2025-04-13

ISAPI_rewrite Chinese manual with multi-site configuration method page 4/4



Code:
[ISAPI_Rewrite]
RewriteRule (.*?\.asp)(\?[^~]*)?~([^~]*)~([^~]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]
Running servers behind IIS


If we have an intranet server running IIS and several company servers running other platforms, these servers cannot enter directly from INTERNET, but can only enter from our company's network, there is a simple example of using proxy tags to map other servers to the IIS namespace:



Code:
[ISAPI_Rewrite]
RewriteProxy /mappoint(.+) http\://sitedomain$1 [I,U]
Moving sites from UNIX to IIS


This rule can help you change the URL from /~username to /username and from /  to /. This is useful when you just move your site from UNIX to IIS and keep search engines and other external pages connected to old pages



Code:
[ISAPI_Rewrite]

#redirecting to update old links
RewriteRule (.*)\.html $
RewriteRule /~(.*) http\://myserver/$1 [R]


Moving site location

Many network administrators ask this question: they want to redirect all requests to a new network server. This problem often occurs when you need to establish an updated site to replace the old one. The solution is to use ISAPI_Rewrite on the old server.


Code:
[ISAPI_Rewrite]

#redirecting to update old links
RewriteRule (.+) http\://newwebserver$1 [R]

Browser-dependent content
Dynamically generated 


It is a search engine that can be indexed. However, it is very complicated to create a file with many dynamic content for a large site. We can write a script

Now generate using a single rule


Code:
[ISAPI_Rewrite]

RewriteRule /robots\.txt /
Making search engines to index dynamic pages


The content of the site is stored in an XML file. There is a / file on the server that processes the XML file and returns HTML to the end user. URLS to the document has the following form
/?xml=/somdir/
But many public engines cannot index such documents because URLs contain question marks (document dynamically generated),
ISAPI_Rewrite can completely eliminate this problem


Code:
[ISAPI_Rewrite]

RewriteRule /doc(.*)\.htm /\?xml=$


Now use a URL like /doc/somedir/ to enter the document, the search engine will not know that it is not a file and the content is dynamically generated

Negative expressions (NOT

Sometimes when the pattern does not match you need to apply the rules, in this case you can use the Forward Lookahead Asserts in the rule expression

For example, you need to move all users to other places without using IE


Code:
[ISAPI_Rewrite]
# Redirect all non Internet Explorer users
# to another location
RewriteCond User-Agent: (?!.*MSIE).*
RewriteRule (.*) /nonie$1
Dynamic authentification


For example, we have some member domains on the site. We need password protection files on this domain and we don't like to use BUILT-IN server security. In this case, you can create an ASP script (called) that will proxy all requests to the member domain and check the request to allow. Here is a simple template that you can put in your own authorization code


Now we need to proxy the request through this page by configuring ISAPI_Rewrite:


Code:
[ISAPI_Rewrite]
# Proxy all requests through 
RewriteRule /members(.+) /\?http\:///members$1
Blocking inline-images (stop hot linking


Suppose we have some inline GIF images on / under /. Others can go to their pages by stealing links without directly negotiating. We don't like this because it increases server traffic.
When we cannot protect images 100% of them, we can at least restrict this situation where the browser sends an HTTP Referer header


Code:
[ISAPI_Rewrite]
RewriteCond Host: (.+)
RewriteCond Referer: (?!http://\1.*).*
RewriteRule .*\.(?:gif|jpg|png) / [I,O]


Multi-site configuration:

Just place the file in the root directory of the corresponding site

ISAPI_rewrite Method to implement IIS second-level domain name unlimited

What I want to achieve is a similar example:
Actual access /?id=xxxx
/ Actual access/?id=xxxx
/ Actual access/?id=xxxx
Many of the online parts were given, but not complete. Many netizens were asking how to achieve such a thing, but no one answered it

After doing many examples, the experiment was finally released
Copy the codeThe code is as follows:

RewriteCond Host: (?!www.)([^.]+).
RewriteRule ^(.*)/ /\?id=$1
RewriteCond Host: (?!www.)([^.]+).
RewriteRule ^(.*)/index\.html /\?id=$1
RewriteCond Host: (?!www.)([^.]+).
RewriteRule ^(.*)/intro\.html /\?id=$1
Previous page1234Read the full text