using .htaccess, I'm looking to redirect a URL from one folder to another.
For example, if a user requests 'forbiddenFolder' http://www.mysite.com/forbiddenFolder/subfolder
or
http://www.mysite.com/forbiddenFolder/somefile.php
or
http://www.mysite.com/forbiddenFolder/somefile.swf
or
http://www.mysite.com/forbiddenFolder/somefile.f4v
.
they should be redirected to http://www.mysite.com/forbidden.php
I don't want to lockdown the directory itself since there are resources there that are required. The redirect should only work based on the URL string OR if the user creates a script from www.anothersite.com and leeches files from http://www.mysite.com/forbiddenFolder
I believe rewrite conditions should be implemented....?
You may try this:
Maps internally
http://www.mysite.com/forbiddenFolder/subfolder
orhttp://www.mysite.com/forbiddenFolder/somefile.php
orhttp://www.mysite.com/forbiddenFolder/somefile.swf
orhttp://www.mysite.com/forbiddenFolder/somefile.f4v
To:
http://www.mysite.com/forbidden.php
For permanent and visible redirection, replace
[L,NC]
with[R=301,L,NC]
OPTION
With a modified incoming URL structure.
For example:
http://localhost/trafficticket.tv/Sites/public_html/forbiddenFolder/somefile.swf
Replace the previous block of rules with this one:
To use any other URL, the only requirement is to prepend the correct segment path to
/forbidden.php
in the rewrite rule. In this case, that segment is/trafficticket.tv/Sites/public_html
but it could be anything or nothing, like in the original question.