[英]Serve static content for an RoR app using .htaccess
How can I give users the ability to upload their content to my RoR application but then subsequent access to such static content that would be: 我如何使用户能够将其内容上载到我的RoR应用程序,然后又可以访问以下静态内容:
served by APACHE web server [to avoid the overhead of going via Rails], but 由APACHE Web服务器提供服务(以避免通过Rails的开销),但是
still want to have an authentication/authorization check to occur before they can access the content 仍然希望在访问内容之前进行身份验证/授权检查
The constraint is I'm on DreamHost shared platform where I have only access to the Apache .htaccess
file and I can't add my own Apache modules. 约束是我在DreamHost共享平台上,在该平台上,我只能访问Apache .htaccess
文件,而不能添加自己的Apache模块。
You can do a redirect to static content, like 您可以重定向到静态内容,例如
class ImagesController
def show
@image = Image.find(params[:id])
if user_has_access_to @image
redirect_to @image.bizarre_and_secret_image_location_that_is_served_by_apache
else
access_denied
end
end
end
It doesn't protect content completely, sure. 当然,它不能完全保护内容。 Maybe making the static URLs temporary will help: 也许将静态URL临时设置将有所帮助:
RewriteRule ^/images/RANDOMIZED_PREFIX_HERE/(.+)$ images/SECRET_IMAGE_LOCATION/$1 [L]
...now change the .htaccess
file each hour. ...现在每小时更改一次.htaccess
文件。 Of course the application should know the prefix, too. 当然,应用程序也应该知道前缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.