Example of whitelist of apache rewrite Rules

Source: Internet
Author: User

Here is a method for configuring the whitelist using rewrite Rules in apache.

Today, I got apache rewrite Rules for half a day, but I still haven't configured any matching rules. My colleague gave me some advice and succeeded.

Requirements:
Six file portals, all others are redirected to the index
Your own ideas:
Regular expressions are used to find out the URL pattern of not six files and filter the URLs.
Comparing the results of colleagues, I have my own ideas:
1. If you want to find out all the rules that do not comply with the rules, the more you want, the more you cannot start. ---------------- Incorrect thinking. A whitelist should be created,
2. Incorrect concept. The basic concepts of REQUEST_URI and REQUEST_STRING are incorrect.
Final result:

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond % {REQUEST_URI} ^/$ RewriteRule ^ /(. *)/index. asp $1 [L] RewriteCond % {REQUEST_URI} ^/index. asp [NC, OR] RewriteCond % {REQUEST_URI} ^/o. asp [NC, OR] RewriteCond % {REQUEST_URI} ^/s. asp [NC, OR] RewriteCond % {REQUEST_URI} ^/error. asp [NC, OR] RewriteCond % {REQUEST_URI} ^/favicon. ico [NC, OR] RewriteCond % {REQUEST_URI} ^/status. taobao [NC, OR] RewriteCond % {REQUEST_URI} ^/app/thirdparty/webbox. asp [NC, OR] RewriteCond % {REQUEST_URI} ^/static/[NC] RewriteRule ^. *-[L] RewriteCond % {REQUEST_URI }! ^/Index. asp $ RewriteRule ^. *-[F, L] </IfModule>

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.