You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Sebastian Tarach <st...@gmail.com> on 2011/09/15 20:13:20 UTC
[users@httpd] Restricting access to all folders except one using mod_rewrite
Hello,
I have all my files that I want clients to have access to in one
folder named assets. I want to forbid direct access to any other
folders and their files.
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule \.(?!assets.+)$ index.php?path=error404
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?path=$1
This does not work for some reason. I mean although it allows access
to any files and folders within assets but it blocks access to non
existing folders. For instance when I type in domain.com/home or
domain.com/contact-us or anything else that isn't a folder it treats
it as a folder ( or file :| ) and redirects me to
index.php?path=error404 instead of executing second set of rules. Why
is that and how to fix it?
Regards
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Restricting access to all folders except one using mod_rewrite
Posted by Eric Covener <co...@gmail.com>.
On Thu, Sep 15, 2011 at 7:55 PM, Sebastian Tarach <st...@gmail.com> wrote:
> I'm just curious why it isn't working when I think it should. For the
> production server I will be using nginx web server either way. I just
> want to learn something useful about Apache. Additionally Directory
> and DirectoryMatch aren't avaiable in htaccess files. So my question
> still remains.
Maybe you're confused by AcceptPathInfo ON. Might be better to test REQUEST_URI.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Restricting access to all folders except one using mod_rewrite
Posted by Sebastian Tarach <st...@gmail.com>.
I'm just curious why it isn't working when I think it should. For the
production server I will be using nginx web server either way. I just
want to learn something useful about Apache. Additionally Directory
and DirectoryMatch aren't avaiable in htaccess files. So my question
still remains.
On 16 September 2011 01:07, Igor Cicimov <ic...@gmail.com> wrote:
> Why dont you use Directory statement instead with Allow/Deny and modify the
> default 404 page?
>
> On Sep 16, 2011 4:13 AM, "Sebastian Tarach" <st...@gmail.com> wrote:
>> Hello,
>> I have all my files that I want clients to have access to in one
>> folder named assets. I want to forbid direct access to any other
>> folders and their files.
>>
>> RewriteCond %{REQUEST_FILENAME} -f [OR]
>> RewriteCond %{REQUEST_FILENAME} -d
>> RewriteRule \.(?!assets.+)$ index.php?path=error404
>>
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteRule ^(.*)$ index.php?path=$1
>>
>> This does not work for some reason. I mean although it allows access
>> to any files and folders within assets but it blocks access to non
>> existing folders. For instance when I type in domain.com/home or
>> domain.com/contact-us or anything else that isn't a folder it treats
>> it as a folder ( or file :| ) and redirects me to
>> index.php?path=error404 instead of executing second set of rules. Why
>> is that and how to fix it?
>>
>> Regards
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Restricting access to all folders except one using mod_rewrite
Posted by Igor Cicimov <ic...@gmail.com>.
Why dont you use Directory statement instead with Allow/Deny and modify the
default 404 page?
On Sep 16, 2011 4:13 AM, "Sebastian Tarach" <st...@gmail.com> wrote:
> Hello,
> I have all my files that I want clients to have access to in one
> folder named assets. I want to forbid direct access to any other
> folders and their files.
>
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d
> RewriteRule \.(?!assets.+)$ index.php?path=error404
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^(.*)$ index.php?path=$1
>
> This does not work for some reason. I mean although it allows access
> to any files and folders within assets but it blocks access to non
> existing folders. For instance when I type in domain.com/home or
> domain.com/contact-us or anything else that isn't a folder it treats
> it as a folder ( or file :| ) and redirects me to
> index.php?path=error404 instead of executing second set of rules. Why
> is that and how to fix it?
>
> Regards
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>