After copying the php project from lampp to apache2, it is found that the restapi of the php project cannot be accessed normally,
Finally, we found that the new environment in the directory did not start support for. htaccess, and recorded the solution process.
1. In the/etc/apache2/mod-enabled directory, create
Ln-s ../mod-available/rewrite. load rewrite. load
Rewrite. load-> ../mod-available/rewrite. load
Rewrite. load file content
LoadModule rewrite_module/usr/lib/apache2/modules/mod_rewrite.so
2. Terminal Operation
Sudo a2enmod
The program prompts the name of the module that can be activated. Enter:
Rewrite
If rewrite already load is returned
3. Modify/etc/apache2/sites-enabled/000-default (the link points to the site configuration file)
Change the AllowOverride attribute under (the default www directory or the directory where the. htaccess application is required) to All and save the attribute.
For example:
DocumentRoot "/var/www"<Directory /> Options FollowSymLinks AllowOverride All</Directory><Directory "/var/www"> Options Indexes FollowSymLinks ExecCGI Includes AllowOverride All Order allow,deny Allow from all</Directory>
4. Relationship between several configuration files of apache2:
Apache2.conf calls httpd. conf, conf. d/, sites-enabled/
Flexible processing during configuration