SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Htaccess subfolders accessing problem

    Hi,

    I'm in a situation where I use the complete url query string in a framework, but when the request is for a file with a certain exentension, apache needs to process this file. The htaccess looks like this:
    Code:
    php_value gpc_magic_quotes off
    php_flag magic_quotes_gpc off
    
    RewriteEngine on
    RewriteRule ^(.*\.(jpg|gif|png|css|js|txt|mpg|wmv|avi|pdf|php|html|reg))$ $1 [L]
    RewriteRule ^(.*)$ index.php?requestUrl=$1 [L]
    The problem I have is that if the request url string starts with a name of one of the subdirectories in the folder and a slash, apache goes into this directory and doesn't call the index.php of the htaccess folder.

    What I need is a way to prevent apache from going into any subdirectories, unless the first rewrite rule is correct (request ends on . and some extension)

    Has anybody done this before or knows how to do this?

    Thanks,
    Bas

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    bas,

    Okay, now you're beginning to see the problem with using .* to match KNOWN character sets.

    And, adding a starting / to the redirection will specify the DocumentRoot for index.php.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

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