(updated) Subfolder needs whitelist and standard redirect for all others

Posted by Superstrong on Server Fault See other posts from Server Fault or by Superstrong
Published on 2010-01-07T07:00:05Z Indexed on 2010/06/15 22:33 UTC
Read the original article Hit count: 221

Filed under:
|
|
|

How can I allow access to the foo.html files in the .com/song/private/ subfolder for:

  • a logged-in Wordpress user; or
  • any referral domains (including subfolders) I add; or
  • any URL on our own domain from the com/song/private folder;

For all others, the user should be redirected to the corresponding public version of the Post, which is the same html filename and structured .com/song/foo.html. (The private versions uses a different template with different custom fields for each Post.)


Update: Here's what I have so far:

<Limit GET POST>

 order deny,allow
 deny from all
 allow from domain.com/song/private
 allow from otherdomain.com

</Limit>

RewriteRule ^(.*)$ ../$ [NC,L]

More:

  1. Will that last rewrite rule take people back to the public version, from com/song/private/foo.html to com/song/foo.html?

  2. I found the following rule for detecting Wordpress logged-in status, but what do I put aferward with a RewriteRule, and will it work anyway? (If not, is there an alternative?)

    RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$

    N.B.

    • I have added code to my root .htaccess allowing me to insert additional .htaccess files in other subfolders as needed.

    • Copied from Stack Overflow, where they suggested I ask here.

© Server Fault or respective owner

Related posts about php

Related posts about .htaccess