Automatic check if mod_rewrite rules are enabled
Sometimes there is a need to check if mod_rewrite rules are enabled or not from a server script and in this post, I will show a method of automatic detection that we use.
To pass all user requests to front-page controller in Modera products we use the following rules:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d #exclude requests to real directories RewriteCond %{REQUEST_FILENAME} !-f #exclude request to real files RewriteRule .+ index.php [L]
For checking if these rules are active we are making HTTP request to predefined URI, which in case of enabled rules will be handled by front-page controller script index.php which will reply with predefined response, if rules are not enabled then this server will return back with a 404 HTTP response.