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;