Different Apache versions and operating systems often have different configuration file names and management methods. for example, the installation directory may be httpd or apache2, configuration file names and loading modules are often different, which may be regular for apache Officials. the configuration file naming and configuration management methods vary with Apache versions and operating systems, for example, the installation directory may be httpd or apache2, and the configuration file name and loading module methods are often different. it may be regular for apache officials, however, after all, most of our users are not network administrators. if we have nothing to do with apache configuration all day long, we are currently looking for information. generally, if the two file paths are incorrect, it will become very popular. Go to the topic.
By default, the Rewrite function of Apache is disabled, but its Rewrite module is loaded. Therefore, we should not just write it. the htaccess file always does not take effect. First, check whether apache has identified us. htacess.
I. check and confirm that the Rewrite module is loaded.
This article is tested on CentOS 6 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 you use the built-in command for installation, such as yum install or apt-get install, it cannot be found in httpd. conf/apache2.conf.
LoadModule rewrite_module modules/mod_rewrite.so
For this line, you can refer to the following settings to load the Rewrite module:
Run
sudo a2enmod rewrite
The Mod_rewrite module is enabled.
In addition, you can connect/etc/apache2/mod-available/rewrite. load to/etc/apache2/mod-enabled/rewrite. load to open the Mod_rewrite module. Instructions:
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
2. check and confirm that the directory Rewrite is enabled.
Loading the Rewrite library does not mean that our. htaccess file will take effect. you also need to enable the AllowOveride switch of the specified directory. the script is as follows:
Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all
AllowOverride can only be defined in the Directory Section. for specific usage, refer to the apache official instructions (below). The above scripts are generally placed in httpd. conf or/etc/httpd/conf. d/vhost. in conf, try to configure the website as much as possible:
....
Together to facilitate maintenance.
III. test the Rewrite function
The following is a. htaccess test instance:
# BEGIN
RewriteEngine on RewriteBase / RewriteRule .*$
#END
Test Method: copy and save the file as. htaccess. upload the file to the root directory of the website. when you access any website path page, the file will jump to this blog, indicating that Rewrite has taken effect.
Related articles:
Rewrite settings of laravel framework in nginx
How to set iis pseudo-static on a windows Server (with rewrite Pseudo-static components)
Detailed Rewrite Pseudo-static rules for Nginx