Htaccess access url from a specific url - both at same domain


the scenario is,

End URL to load at the html page is


But this should be only loaded if the user comes via


When user will click urlB it will check the id of report and load the urlA. So, effectively I dont want to give access to url A to any other person.

I have tried something like this but doesnt work

SetEnvIf Referer "^" local_referral #SetEnvIf Referer "^" auth_referral Order Deny,Allow Deny from all Allow from env=local_referral #Deny from env=auth_referral

I have put this htaccess in report_files directort so that the user with local_referral is allowed only. I have commented the lines for auth_referral because i need to load the swf file from it as well. I am new to this so dont know for sure what can fix it.

Another solution i found and tried is

RewriteEngine On RewriteCond %{HTTP_REFERER} !(www.)? RewriteRule .* - [F]

It is working. But the swf files folder is not allowed access and gives 403 forbidden access error for them. The swf folder structure is


Actually swf file in X uses some helping files e.g. fonts, images etc from /files/ inside the /reports/ directory. And the referrer for it is changed.

I think I need nesting solution.