Apache htaccess minify Formal Environment no access to rewrite rules

Source: Internet
Author: User

Google Project Minfiy is placed under the site root directory/min/.

If it is a formal environment (judging the condition, the domain name Http_host exists. The dot is judged to be the official on-line environment), then does not rewrite the website CSS js to min/index.php

If it is a test environment (judging the condition, the domain name Http_host does not exist.), or 192.168. Beginning or other special case, there is a special case), then the web site of Css/js Real files are all rewritten.

and the limited rewrite CSS JS is only the css/js! in the/public/public/css/js folder


Implementation code: htaccess, only support Apache server:

#if the formal environment, do not rewrite to the compressionRewritecond%{http_host}!\. [NC]Rewritecond%{request_filename} (\. ( JS|CSS)) $ [NC]Rewriterule^ ((css|js|public) \/.*\. ( CSS|JS) $ min/index.php?f=$1 [L,NE,NC]#formal environment, access/minDirectory JumpRewritecond%{http_host} \. [NC]Rewritecond%{request_filename}-FRewriterule^ (min\/.*) $/?=$1 [l,r=301]

If there is a problem, or if there are better suggestions, please communicate. by [email protected]



——————————————— additional ———————————————————

Modify the/min/.htaccess file if it is a formal environment, prohibit any access!

<Ifmodulemod_rewrite.c>Rewriteengine on# need rewritebase on some servers#RewriteBase/min#formal environment, no accessminfolder any Content!   Rewritecond%{http_host} \. [NC]  Rewriterule^ (. *) $/?f=$1 [l,r=301]# rewrite URLs like "/min/f= ..." to "/min/?f= ..."Rewriterule^ ([bfg]=.*) index.php?$1 [L,ne]</Ifmodule><Ifmodulemod_env.c># in case Addoutputfilterbytype have been addedSETENVNo-gzip</Ifmodule>



Apache htaccess minify Formal Environment no access to rewrite rules

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.