1, about the Apache 2.x URL alias description and settings;
A document of the URL alias rule in the Apache 2.x server, which is implemented through the rewrite module. The URL alias rule allows us to see a clean URL, such as an address that can be rewritten like a static web page. For example, in the Linuxsir.org forum, each post has a static page address. Clean URL, for the Google search engine is extremely useful, can be included faster.
This rewrite, which is implemented within the Apache 2.x, is simply a clean URL to the Web application, and the original URL is just as valid.
1.1 on the rewrite module of the call;
URL rewriting in Apache 2.x is done through mod_rewrite.so, so you want to see if your Apache has been compiled into this module, and this module has been called in Apache's configuration file httpd.conf. In most mainstream distributions, the Apache 2.x is the rewrite module has been programmed in. For example, I'm using a slackware. The Apache 2.x configuration file is placed in the/ETC/HTTPD directory.
In httpd.conf, we will find a row similar to the following, which is about the rewrite module, and 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 # number in front of you, you should remove it. For most distributions, the Apache 2 module is typically located in the following two locations
/usr/lib/apache2/modules
Or
/usr/lib/httpd/modules
If you open the call Rewrite_module setting in httpd, check to see if it can be invoked, by httpd-m parameters;
#/usr/sbin/httpd-m
If the following line is found, the module can already be invoked
Rewrite_module (Shared)
1.2 Setting up the directory of DocumentRoot;
In Apache 2.x, we see a row of documentroot settings. This line is where the Web page is stored. For example, linuxsir.org is stored in the/opt/www directory. Then we will set the DocumentRoot as follows.
DocumentRoot "/opt/www"
Then we have to do to the documentroot to do targeted behavior settings. In general, the httpd.conf will give a default. If you want to change the DocumentRoot path, also change to the DocumentRoot directory settings, which is
<directory "DocumentRoot set path" >
For example, we have changed the path of DocumentRoot to "/opt/www", then we also want to DocumentRoot do targeted behavior settings to be changed to this path.
<Directory "/opt/www">
Options FollowSymLinks
#AllowOverride None 注:把这行前面加#号,然后加下面的一行 ,也就是 AllowOverride ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
We set the allowoverride parameter to all, which means that URL rule overrides are supported on the entire server. The Apache server reads the. htaccess file in the home directory under each Web site. If this file is not available, or if the document does not define any rules about URL rewriting, it will not have any effect. In general, a mature Web server application suite supports URL rewriting, such as Drupal and Joomla. When we use these programs, we find that there is a file in the installation package in the. htaccess. After we have configured Apache, we just need to open this feature in the background of these programs.