Forum Moderators: phranque
Imagine I had a web page called internal.html - but, I wanted people to access this resource through the url www.example.com/external.html. AND, on top of that, I wanted www.example.com/internal.html to return as 'Forbidden'.
I've been trying to achieve this effect with .htaccess for ages now, and am not being very successful. This is my best attempt so far:
RewriteCond %{ENV:myvar} !val
RewriteRule ^internal.html$ internal.html [F]
RewriteRule ^external.html$ internal.html [ENV=myvar:val,N]
How does one get around this? Replies very much appreciated...
throwing away the environment variables
REDIRECT_oldvar. Use
%{THE_REQUEST} instead which contains the request string like GET /foo?args HTTP/1.1 if you can't avoid the per-directory context. [edited by: Caterham at 6:00 pm (utc) on Dec. 30, 2008]
# Forbid direct client access to "/internal.html"
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /internal\.html\ HTTP/
RewriteRule ^internal.html$ - [F]
#
# Internally rewrite requests for "external.html" to "internal.html"
RewriteRule ^external.html$ internal.html [L]
Jim