Apache2 adds rewrite

Source: Internet
Author: User

Apache add rewrite Module
1. Install gdbm
Add rewrite function for Apache compilation, add rewrite compile, need gdbm, the server does not exist need to download and install first,: ftp://ftp.gnu.org/gnu/gdbm/ to check whether there is already: rpm-Qa gdbm (the related package has been downloaded to the server/root/gdbm-1.8.3.tar.gz)
1, tar-zxvf gdbm-1.8.3.tar.gz
2, CD gdbm-1.8.3
3,./configure
4. Make
5. Make install
6. Make insatall-compat (this step must be executed; otherwise, the ndbm. h header file cannot be compiled)
2. Compile and install the rewrite Module
Go to the Apache source directory (under/root on the server)
1, CD/root/httpd-2.0.59/modules/mappers
2, manually compile mod_rewrite.c into a mod-rewrite.o file:
/Home/apache2.0/bin/apxs-C mod_rewrite.c-lgdbm #/home/apache2.0 is the installation directory of Apache.
3. manually compile the rewrite module: gcc-shared-O mod_rewrite.so mod_rewrite.o
Now we can see that mod_rewrite.so has been generated in the current directory, and the next step is to load it to httpd. conf (you can also manually)
4. Install/home/apache2.0/bin/apxs-I-a-n rewrite mod_rewrite.so.
#/Home/apache2.0 is the Apache installation directory
5. Modify the httpd. conf file and enter httpd. conf. The rewrite file is loaded and the comment is canceled.
6. Run the configuration file check command.
Apache/bin/apachectl configtest # If syntax OK is displayed, the operation is successful.
3. Application of the rewrite Module
The rewrite function is very powerful, and the Code for re-writing rules can be written in:
Httpd. conf
<Virtualhost> label defined in httpd. conf
Across the configuration file. htaccess.
In this example, <virtualhost> of the simplest application in httpd. conf is added as follows:
Rewriteengine on # enable the rewrite Function
Rewriterule ^/$/Lala [R] # rewrite all Apache requests to the/Lala directory
Note: [R] indicates permanent rewriting by default or [R = 302]. 302 indicates permanent rewriting.

This article from: (www.91linux.com) detailed source reference: http://www.91linux.com/html/article/guanli/20080619/12652.html

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.