Apache version of different, operating system, its configuration file naming, configuration management methods are often different, such as the installation directory may be httpd, also may be apache2, the configuration file name and loading module mode is often different, perhaps for the official Apache is a regular, But after all, most of our users are not network management, nothing to configure Apache all day, are now used to find information, generally two file path is not always the fire big. Go to the chase.
The Apache default rewrite feature is disabled, but its rewrite module is loaded, so let's not just be busy writing. htaccess files, which always do not take effect, first check if our Apache has identified our. htacess.
One, check confirm rewrite module loading
This test is on the CentOS 6 system with the path:/etc/httpd/conf/httpd.conf
LoadModule Rewrite_module modules/mod_rewrite.so
If there is a comment above, remove it and restart Apache.
If the system comes with command installation, such as Yum Install or Apt-get install, cannot be found under httpd.conf/apache2.conf
LoadModule Rewrite_module modules/mod_rewrite.so
This line, you can refer to the following settings to load the rewrite module:
Executing in the terminal
sudo a2enmod rewrite
command, the Mod_rewrite module is enabled.
Alternatively, you can open the Mod_rewrite module by connecting the/etc/apache2/mods-available/rewrite.load to the/etc/apache2/mods-enabled/rewrite.load. The command operation is:
sudo ln-s/etc/apache2/mods-available/rewrite.load/etc/apache2/mods-enabled/rewrite.load
Second, check the confirmation directory rewrite open
Rewrite library loading does not mean that our. htaccess file will take effect, but also requires a special open allowoveride switch for the specified directory, as follows:
<Directory/var/www/> Options Indexes followsymlinks allowoverride all Order allow,deny allow From all</directory>
Where allowoverride can only be defined in the section of the directory, the specific usage can refer to the official Apache instructions (links below), the above script is generally placed in httpd.conf or/etc/httpd/conf.d/ Vhost.conf below, try to configure the site as much as possible:
<virtualhost ...> ....</virtualhost>
Defined together for easy maintenance.
Third, test rewrite function
The following is a. htaccess Test example:
# begin<ifmodule mod_rewrite.c> rewriteengine on rewritebase/ rewriterule. *$ </ifmodule > #END
Test method, copy saved as. htaccess, upload to the site root directory, visit any path page of the site, will jump to this blog, indicating that rewrite has been in effect.
Related articles:
setting of Laravel frame rewrite under Nginx
IIS pseudo-static Setup method under Windows Server (with rewrite pseudo-static component)
Nginx detailed rewrite pseudo-static rule steps