Apache Magic (rewrite rules) completely abandon IIS

Source: Internet
Author: User
Article title: Apache Magic (rewrite rules) completely abandons IIS. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   (1) Proxy ):
I wonder if you have noticed the Apache Proxy function. Since I used IIS to support ASP. NET, but now I have abandoned IIS, there is a sharp problem: how to deal with the original ASP. NET program? Make Apache support ASP. NET is obviously unrealistic. at least there is not yet a complete solution (MONO). now it is just an experimental thing. besides, it is still a thing in linux. So I thought of the Apache Proxy function. Accessing IIS through Apache Proxy is like Apache supports ASP. NET.
Add the following content to your Apache Httpd. conf file. Port 88 is the port used by your IIS.
ProxyPass/home/http: // 127.0.0.1: 88/
ProxyPassReverse/home/http: // 127.0.0.1: 88/
RewriteRule ^/home $/home/[R]
In this way, you can access your IIS through http: // localhost/home/. does Apache support Asp/Asp.net in disguise?
In fact, you can also use this method to create a fake image of a website, so that the viewer thinks that you have made an image of another website:
ProxyPass/home/http://www.sina.com.cn/
ProxyPassReverse/home/http://www.sina.com.cn/
RewriteRule ^/home $/home/[R]
Next visit http: // localhost/home/. is it already the homepage of www.sina.com.cn?
Is it amazing?
  
   (2) rewrite:
I often see that the URLs on some websites are like this? Wrong, your eyes are deceiving your mind. Such a url may point to a dynamic page. this is another magic of Apache: rewrite. (This part requires some knowledge about regular expressions)
In my Httpd. conf, a dynamic URL is rewritten to a static URL.
RewriteRule/box/([^/] *)? /([^/] *)/([^/] * Character .html/box/view. do? ID =/$1/$2/$3 [P]
It's easy. There are three "([^/] *) from left to right. ", Which means to match any character of any length. the three following characters are passed as parameters of dynamic URLs, obtaining the corresponding page and returning it to the viewer [P] is to keep the original static url unchanged. for other parameters, refer to the Apache user manual. The advantage of this is that it is easily collected by the search engine, because the search engine crawls html with a higher priority than dynamic URLs by default, so it is easy to be searched by the search engine.

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.