#1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,402
    Rep Power
    0

    Restrict a file if a specific query sting is present


    Hello,

    I want to restrict access to a python script and iam suing this:

    <FilesMatch "pelatologio.py">
    AuthName "Admin Access Only!"
    AuthType Basic
    AuthUserFile /aboslute_path
    require user nikos
    </FilesMatch>

    Problem is that the link that is being used to access "pelatologio.py is as follows:

    500 Internal Server Error

    So, what i want to ask you guys is HOW to match this specific request within my .htaccess file and if possible how to match any request to any python file if a query sting like "page=pelatologio.py" is present

    Thank you.
  2. #2
  3. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,402
    Rep Power
    0
    Actually to say it even better with english words:

    I want basic authentication to be triggered if a request is been made to "pelatologio.py" that involves the query string "page=pelatologio.py"
  4. #3
  5. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,265
    Rep Power
    4193
    You could probably use an <If> directive.

    Code:
    <If "%{QUERY_STRING} =~ /page=pelatologio.py/">
       ...
    </If>
    The problem with trying to use <files> or is that as far as apache is concerned that request is to index.html and your python file is not involved in any way. <location> also doesn't work because it only matches against the path, not the query string.

    What is index.html exactly? Is it a Python script that includes the specified file? If so, I'd probably do your check there rather than in apache.
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  6. #4
  7. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,402
    Rep Power
    0
    It worked like a charm!

    inde.xhtml is the main template which is being read by my main.py script that opens it up and reroutes all traffic through it.
    That means that my python files runs implicitly from within one other main.py script.

    Cna i ckeck for 2 confitions as well?
    How to check if a request is been made to "pelatologio.py" along with the query string "page=pelatologio.py" ?

IMN logo majestic logo threadwatch logo seochat tools logo