Hello all,

I am looking for some help. I have a website that contains a folder with some html * php files in it.

What I need to do is prevent direct access to those files unless you clicked my site to get their.

For example:

if a visitor click a link view.php they can view the file.

if a user enters the url into their browser they cannot view the file.

I have been reading up on this and it seems that .htaccess and mod_rewrite may work based on referer, but alas this is totally beyond me.

Any help would be appreciated. Thanks

Liisa

    8 days later

    Try this in your .htaccess file, but replace "YOURSITE.COM" with whatever your website is, and /PATH with the path to your protected PHP files.

    I have not tested it, so give it a try and let me know how it works out.

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !$
    RewriteCond %{HTTP_REFERER} !http://YOURSITE.COM/(.)$ [NC]
    RewriteCond %{HTTP_REFERER} !http://www.YOURSITE.COM/(.
    )$ [NC]
    ReWriteRule /PATH/.(php|html|htm)$ - [N,F,L]

      Write a Reply...