Posted By

phpdev on 08/02/13


Tagged

check server engine apache module mod extension rewrite


Versions (?)

Check if Apache's mod_rewrite is installed.


 / Published in: PHP
 

Example:

   if (!isRewriteMod()) exit('Please install Apache mod_rewrite module.');
  1. /**
  2.  * @title Check if Apache's mod_rewrite is installed.
  3.  *
  4.  * @author Pierre-Henry Soria <[email protected]>
  5.  * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved.
  6.  * @return boolean
  7.  */
  8. function isRewriteMod()
  9. {
  10. if (function_exists('apache_get_modules'))
  11. {
  12. $aMods = apache_get_modules();
  13. $bIsRewrite = in_array('mod_rewrite', $aMods);
  14. }
  15. else
  16. {
  17. $bIsRewrite = (strtolower(getenv('HTTP_MOD_REWRITE')) == 'on');
  18. }
  19.  
  20. return $bIsRewrite;
  21. }

Report this snippet  

You need to login to post a comment.