1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_rewrite problem

Discussion in 'HTML, Graphics & Programming' started by toastyman, 23 Jul 2009.

  1. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Evening all! I've got a bit of a problem with htaccess..

    Code:
    Options +FollowSymLinks -Indexes
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php
    
    If a user visits http://willesley.org/shop this works fine, as the file doesn't exist so mod_rewrite passes it to /index.php which looks it up in the cms.

    The same goes for http://willesley.org/shop?edit which passes 'edit' as a GET variable to /index.php.

    http://willesley.org/campsite/ is an empty directory (no index file). Visiting this redirects to /index.php (as it should)

    http://willesley.org/campsite/?edit doesn't work - it doesn't pass the GET variable to /index.php. Anyone got any ideas why this is?
     
  2. philldutton

    Associate

    Joined: 30 Apr 2004

    Posts: 48

    Are you sure the variable isn't being passed?

    I've knocked up a quick test page using the htaccess you've provided and used the following as my index.php to check what's being passed in the GET array and it seems to work ok.

    PHP:
    <html>
        <body>
                  // loop through each querystring variable in the $_GET array and echo out each one's variable name ($keyname) and $value.
                <?php
                    
    foreach($_GET as $keyname => $value) {
                       echo(
    "$keyname --&gt; $value.<br />\n");
                    } 
                 
    ?>        
        </body>
    </html>