Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,738

    Detecting mod_rewrite

    I have written this code to determine if mod_rewrite is being used.

    PHP Code:
    $filec = @file_get_contents(".htaccess");
    if(
    strpos($filec"RewriteEngine On") != false){
    //no mod_rewrite detected

    It doesnt work for some reason. strpos is supposed to output a boolean false but still it gives an error.

    Is there another function I could use?

    Any ideas?
    Thanks.
    <<< Please see Forum Guidelines for signature setup. >>>

  2. #2
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    In .htacess, you can just put :

    Code:
    <IfModule mod_rewrite.c>
      RewriteEngine On
      # Rewrite rules go here
    </IfModule>
    The rewrite rules are only active if the module is compiled into Apache.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  3. #3
    Join Date
    Dec 2003
    Location
    Sunny So. Calif.
    Posts
    204
    Use the following code example to see how it should work:

    <?php
    $filec = @file_get_contents(".htaccess");
    if (strpos($filec, "RewriteEngine On") != "") {
    echo "Present in file";
    }
    else {
    echo "Not found in file";
    }
    ?>

    It does not return boolean false, just null

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •