Apache opens URL rewriting function method

  
                  

1, on the call to the rewrite module: URL rewriting in Apache 2.x, is achieved through mod_rewrite.so, so you have to check whether your Apache has been compiled into this module, and in the Apache configuration This module has been called in the file httpd.conf. In most major distributions, Apache 2.x has incorporated the rewrite module. For example, I use Slackware. The Apache 2.x configuration file is placed in the /etc/httpd directory. In httpd.conf, we will find a line similar to the following, which is related to the rewrite module, the module name is mod_rewrite.so. LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so or LoadModule rewrite_module lib/apache2/modules/mod_rewrite.so If there is a # before it, you have to remove it. For most distributions, the Apache 2 module is typically located in two locations: /usr/lib/apache2/modules or /usr/lib/httpd/modules. If you open the call to rewrite_module in httpd, check to see Can not be called, to be viewed through the httpd-M parameters; #/usr/sbin/httpd -M If you find the following line, the module can be called rewrite_module (shared) 2, set the DocumentRoot Directory: In Apache In 2.x, we will see a line set by DocumentRoot. This line is where the web application is stored. For example, LinuxSir.Org is stored in the /opt/www directory. Then we have to set DocumentRoot as follows. DocumentRoot "/opt/www" Then we have to do specific behavioral settings for DocumentRoot. In the general case, httpd.conf will give a default. If you want to change the path of DocumentRoot, you must also change the setting of DocumentRoot's Directory, that is, the path set by <Directory "DocumentRoot"> For example, we changed the path of DocumentRoot to "/opt/www" Then, we also need to change the Directory's targeted behavior settings to this path. <Directory "/opt/www"> Options FollowSymLinks #AllowOverride None Note: Put this line in front of the # sign, then add the following line, which is AllowOverride ALL AllowOverride ALL Order allow, deny Allow from all </Directory> ; We set the AllowOverride parameter to ALL, which means that the entire server supports URL rule rewriting. The Apache server reads the .htaccess file in the root of each website. If you don't have this file, or if the document doesn't define any rules for URL rewriting, it won't work. In general, mature web server application suites support URL rewriting, such as drupal and joomla. When we use these programs, we will find this file in .htaccess in the installation package. After we have configured Apache, we just need to open this function in the background of these programs. 3. Restart the httpd server: Under normal circumstances, there are httpd server startup scripts in each distribution, such as # /etc/rc.d/rc.httpd restart Note: Slackware Linux # /etc/init.d/apache2 Restart Note: ubuntu, Debian, etc.; # /etc/init.d/httpd start Note: Fedora, Redhat, CentOS

Copyright © Windows knowledge All Rights Reserved