In apache,. htaccess is generally used in virtual hosts to take advantage of this function when there is no permission to operate the server. It needs to enable apache-related modules. Mod Rewrite can be directly included in the apache conf file.
The Mode Rewrite module of Apache provides a Rewrite engine based on regular expression analyzer to Rewrite URLs in real time.
Windows
In Windows, we generally use the Administrator account, so enabling these two items is very simple:
Find # LoadModule rewrite_module modules/mod_rewrite.so in the [Apache installation directory]/conf/httpd. conf and remove the annotator #. If this row does not exist, add it. Check whether the mod_rewrite.so file exists in the modules folder under the apache installation directory. In this way, the Mod Rewrite function is enabled.
In the [Apache installation directory]/conf/httpd. conf, find
The Code is as follows: |
Copy code |
<Directory/> Options FollowSymLinks AllowOverride None Order deny, allow Deny from all </Directory> |
Change "AllowOverride None" to "AllowOverride All", so that All folders are supported. htaccess or enabled for the specified folder. htaccess, which can be found in the [Apache installation directory]/conf/httpd. add in conf
The Code is as follows: |
Copy code |
<Directory "D:/sites/example/"> Options Indexes FollowSymLinks AllowOverride All Order allow, deny Allow from all </Directory> |
This approach is generally configured with the virtual host, so most will write the above configuration code into the [Apache installation directory]/conf/extra/httpd-vhost.conf, which is clear and easy to manage.
After Apache is restarted, it will be OK.
After the appeal step is completed, use the link settings except the default settings in the fixed link of Wordpress. Wordpress will generate the corresponding link in its installation directory directly. htaccess.
Mac OS X
In Mac OS X, the root account is generally not used, but the root permission is obtained through sudo. In general, we place website files in a personal directory, such ~ /Sites, which involves Mac OS permission management, which is much more complicated than Windows.
Run sudo vi/etc/apache2/httpd. conf on the terminal, find # LoadModule rewrite_module modules/mod_rewrite.so, and remove the annotator #.
Run sudo vi/etc/apache2/extra/httpd-vhost.conf and add
The Code is as follows: |
Copy code |
<Directory "/Users/[user name]/Sites"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow, deny Allow from all </Directory> |
So the whole ~ /Sites supports. htaccess.
Run sudo vi/Private/etc/apache2/users/[user name]. conf and change AllowOverride None to AllowOverride All. Note that in the previous Mac OS X version, the path may be/private/etc/httpd/users/[user name]. conf.
Create. htaccess in the required directory and change the permission to 777. Here, we still use the Wordpress fixed link as an example.
Cd ~ /Sites/Wordpress
Touch. htaccess
The default permission for chmod 777. htaccess to create a new file is 644. You can see it through ls-l. htaccess. At this time, the program cannot automatically write to. htaccess. This situation is safer, but manual writing is required.
Restart Apache after exiting: sudo apachectl restart
After completing the preceding settings, you can use the Wordpress fixed link function. Note that if. htaccess is directly copied from Windows, an error may occur in the </IfModule> without matching <IfModule> section in the log. A simple solution is to create a file and copy and paste it again.