Enabling mod_rewrite across Operating Systems
Despite misconceptions, mod_rewrite is an Apache module unrelated to PHP. To activate it, you must modify the httpd.conf file.
Apache Configuration Steps
Load the mod_rewrite module by adding the following line to httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so
Testing Activation
Create an .htaccess file and place it within a web directory. Inside the file, include the following line:
RewriteEngine on
If this action does not trigger a 500 internal server error and the .htaccess file is parsed successfully, URL rewriting is enabled.
Platform-Specific Considerations
The steps outlined above apply to most operating systems that support Apache. However, it's worth noting that some platforms may require additional configuration. For example, on Debian-based systems, it may be necessary to issue the following command to enable mod_rewrite:
sudo a2enmod rewrite
The above is the detailed content of How to Enable mod_rewrite for Apache across Different Operating Systems?. For more information, please follow other related articles on the PHP Chinese website!