How to check if mod_rewrite is enabled in php?
If you're using mod_php, you can use apache_get_modules()
. This will return an array of all enabled modules, so to check if mod_rewrite
is enabled, you could simply do
in_array('mod_rewrite', apache_get_modules());
Unfortunately, you're most likely trying to do this with CGI, which makes it a little bit more difficult.
You can test it using the following, though
strpos(shell_exec('/usr/local/apache/bin/apachectl -l'), 'mod_rewrite') !== false
If the above condition evaluates to true
, then mod_write
is enabled.
why isn't my mod_rewrite working even when it is enabled?
Please change the conf as below to allow the access in your /etc/apache2/sites-available
or /etc/httpd/conf.d/
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
Related Topics
I Have an Array of Integers, How to Use Each One in a MySQL Query (In PHP)
Having Issue With Matching Rows in the Database Using Pdo
Setting Up a Deployment/Build/Ci Cycle For PHP Projects
PHP Preg_Match to Find Multiple Occurrences
How to Find the PHP.Ini File Used by the Command Line
Finding N-Th Permutation Without Computing Others
Json_Encode() Escaping Forward Slashes
Execute PHP Script in Cron Job
How to Upload Multiple Files Using PHP, Jquery and Ajax
Are PHP Include Paths Relative to the File or the Calling Code
Get Sum of MySQL Column in PHP
Glob() - Sort Array of Files by Last Modified Datetime Stamp
Get PHP to Stop Replacing '.' Characters in $_Get or $_Post Arrays