Introduction: This is a detailed page for Apache to enable the rewrite environment. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 336645 'rolling = 'no'>
Environment:
Windows
In Apache 2.2
Load the rewrite module:
Find httpd. conf In the conf directory
Loadmodule rewrite_module modules/mod_rewrite.so
Remove the comment symbol "#" from the front or add this sentence.
You can use the ". htaccess" file in any directory and change "AllowOverride" to "all" ("NONE" by default "):
# AllowOverride controls what directives may be placed in. htaccess files.
# It can be "all", "none", or any combination of the keywords:
# Options fileinfo authconfig limit
#
AllowOverride all
In Windows, the ". htaccess" file cannot be created directly. You can use "echo a>. htaccess" on the command line to create the file, and then use NotePad to edit it.
Simple Application of the Apache rewrite module:
All rewrite judgment rules are based on Perl-style regular expressions. You can use the following basic examples to write the rules that meet your own jump requirements.Code.
1. Request jump
If the request is a. jsp file, it is redirected to another domain name for access.
For example
Note: The Meta or JavaScript method in HTML technology is not used, because the file www.clin003.com/a.php does not exist, and the rewriteiterator in the apache2.2server is used.
Modify the httpd. conf file of the. htaccess or Apche configuration file and add the following content:
Rewriteengine on
# Enable rewrite Module
Rewriterule (. *) \. php $ http:// B .clin003.com/41012.16.jsp [R = 301, L, NC]
# Intercept all. jsp requests, jump to http:// B .clin003.com/add the original request and add .php. R = 301: 301 jump, L is the end of the rewrite rule, NC is case-insensitive
2. Domain Name jump
If the request is all URLs under old.clin003.com, jump to B .clin003.com
Rewriteengine on
# Enable rewrite Module
Rewritecond % {remote_host} ^ old.studenthome.cn $ [Nc]
# Process the host whose host is old.clin003.com. ^ indicates the start character and $ indicates the end character.
Rewriterule (. *) http:// B .clin003.com/#1 [R = 301, L, NC]
3. Anti-leech
If you do not want other websites to call images on this website, you can add the following content to the. htaccess or Apche configuration file httpd. conf.
Rewriteengine on
# Enable rewrite Module
Rewritecond % {http_referer }! ^ $
# If you do not directly enter the image address
Rewritecond % {http_referer }! Img.clin003.com $ [Nc]
# If not all subdomains of img.clin003.com are called
Rewritecond % {http_referer }! Img.clin003.com/(. *) $ [Nc]
Rewritecond % {http_referer }! Zhuaxia.com [Nc]
Rewritecond % {http_referer }! Google.com [Nc]
Rewritecond % {http_referer }! Google.cn [Nc]
Rewritecond % {http_referer }! Baidu.com [Nc]
Rewritecond % {http_referer }! Feedsky.com [Nc]
Rewriterule (. *)\. (JPG | JPEG | jpe | GIF | BMP | PNG | WMA | MP3 | WAV | Avi | MP4 | FLV | SWF) $ http://clin003.com/err.jpg [R = 301, L, NC]
Screenshot capture all .jpg or .jpeg ...... Request, jump to Pipeline
On the Windows Apache application environment tower construction: http://clin003.com/ideas/windows-apache-install-useing-like-php-python-subversion-1330/
Application about 301 redirection: http://clin003.com/search-engine/301-redirect-implementation-784/
Use telnet to detect the header information returned by the Web Site status code: http://clin003.com/servers/detection-using-telnet-to-return-at-the-head-of-the-state-code-information-450/
TodayProgramRewrite is required, so modify the configuration.
Easysns (Deleted)
More articles about "Apache enables rewrite Environment"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/336645.html pageno: 10.