fart-y-goer
fart-y-goer

Reputation: 739

Process the form if the action reference to a php file in a deny from all directory

This is the structure

in the index.php I have this form

<form method='post' action='/app/processor.php'>
    <input type='text' name='foo' value=''/>
    <input type='submit' value='bar'/>
</form>

The file which will process the form is located inside the app folder. The processor.php has the code:

<?php
    if(isset($_POST['foo'])){
        echo "foo is set";
    }
?>

And inside the app folder, I created a .htaccess to deny direct access of the files inside of it.

Order deny,allow
Deny from all

My problem now is that I can't process the form due to the .htaccess file. The server returns error 403 because of that restriction in the app folder. Is there anyway I can process the form by still using the processor.php? Or should I remove/modify the .htaccess? Thanks for your answers!

Upvotes: 1

Views: 291

Answers (2)

Mattias Ahnberg
Mattias Ahnberg

Reputation: 2860

Above the Order deny,allow you can always add a section like:

<Files processor.php>
Allow from all
</Files>

And it should allow that specific file to be read, while everything else remains forbidden.

Upvotes: 1

Radix
Radix

Reputation: 667

Absent modification of the .htaccess file, there is no way to execute the code in your /app/processor.php.

Upvotes: 0

Related Questions