2017-03-31 20 views
0

我有一个包含个人重写规则映射/services文档根目录中的文件services.html共享的托管服务本地.htaccess文件。Apache的mod_rewrite的和隐藏的源文件同时

RewriteEngine On 
RewriteBase/
RewriteRule ^services$ services.html [L] 

如何防止消费者直接访问/services.html(如果他们嗅左右吧),并让他们收到404 HTTP响应呢?我做而不是想要任何消费者知道我有一个services.html文件,并且包括发送302将回到原始/services资源的答复。

但是,我试图设置规则返回404的/services.html但这导致/services也返回404。总之,我希望消费者只能看到/services端点(200 OK),永远不知道它背后映射的是什么,或绕过公开选择的端点(services.html返回404 Not Found)。

+0

如果你downvoted,你不介意分享的原因?据我了解你的问题,你想调用/服务,并从DocumentRoot获取services.html,但不希望URL/URI改变... [P]这样做。 –

+0

@HelloFishy反对票不是我的。 – codemagician

回答

-1

只需'隐藏'您的services.html并首先使用[P]参数代理请求。

RewriteEngine On 
RewriteBase/
RewriteRule ^/services$ http://yourdomain.com/<path-to-the-file>/services.html [P,L] 

这需要一个请求像http://yourdomain.com/services并返回http://yourdomain.com/ /services.html没有表现出它是从哪里来的用户,浏览器仍然会显示/服务