Common php and apache pseudo-static code

Source: Internet
Author: User
This article introduces the application of. htaccess and php pseudo-static in actual projects, some common code of php and apache pseudo-static 1. Setting image anti-Leech in htaccess

RewriteEngine on##################################################RewriteCond %{HTTP_REFERER} !^$RewriteCond %{HTTP_REFERER} !^http://(www\.)?php1.cn(/)?.*$ [NC]RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://nothing_phpcn[R,NC,L]##################################################################################RewriteCond $1 !^(index\.php|statics|upload|app\.html|robots\.txt)RewriteRule ^(.*)$ /index.php?/$1 [L]

2. htaccess setting 404 500 error page

ErrorDocument 404 /statics/home/notfound.htmlErrorDocument 500 /statics/home/notfound.html

3. phpstudy pseudo static error No input file specified solution

Apache No input filespecified. this problem occurs when we configure apache RewriteRule. the solution is as follows:

Open. htaccess and add "?" to the index. php tutorial after RewriteRule.

The complete code is as follows:

.htaccessRewriteEngine onRewriteCond $1 !^(index.php|images|robots.txt)  RewriteRule ^(.*)$ /index.php?/$1 [L]

4. Modules cannot be loaded in non-root directories of Thinkphp.

. Htaccess and RewriteBase/demo2/\ demo2 \ ThinkPHP \ Library \ Think \ Dispatcher. class. php 119 line define ('_ INFO _', trim ($ _ SERVER ['path _ info'], '/'); add: $ _ SERVER ['path _ info'] = str_replace ('/demo2', '', $ _ SERVER ['path _ info']);

5. CI frame pseudo-static iis-web.config Configuration Reference

 
     
          
               
    
                 
                         
                      
                     
                         
                                          
                           
                         
                                          
                 
            
       
  
 

6. remove index. php from the pseudo-static state of thinkphp

 
  RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
 

Enable routing:
'URL _ ROUTER_ON '=> true, // URL routing
'URL _ model' => 2, // URL mode

7. pseudo-static rule conversion between httpd. ini and. htaccess

 'DB, htaccess ',.....);


Htaccess. php

 True, // enable the route 'URL _ ROUTE_RULES '=> array (// define the routing rule'/^ verifycode \/(\ w +) $/'=> 'G = Index & c = Verifycode & a = index & type =: 1 ', // verification code '/^ upload_image $/' => 'g = Index & c = Image & a = upload ', // tutorial image upload button/* logon related */'/^ login \/login $/' => 'g = Index & c = Login & a = login ', // log on '/^ login \/reg $/' => 'g = Index & c = Login & a = reg ', // register '/^ login \/logout $/' => 'g = Index & c = Login & a = logout', // log on),); return $ rules;
Related Article

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.