无需访问 htdocs 即可重写地图
我在虚拟服务器上,所以我无法访问 Apache 的 htdocs;我只有 .htaccess。还可以重写地图吗?有哪些解决方法?
I'm on a virtual server so I don't have access to Apache's htdocs; all I have is .htaccess. Is it still possible to do a rewrite map? What kind of workarounds are there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您阅读文档,您将看到,在名为“Context”的文档字段中,RewriteMap 指令可以在服务器配置或虚拟主机配置中使用。在目录或 .htaccess 中不允许这样做 - 明确地说,答案是否定的,如果您有权访问的只是 .htaccess,则仍然无法进行重写映射。
http://httpd.apache.org/docs/current/mod/ mod_rewrite.html#rewritemap
唯一的“解决方法”是为您需要的每个映射定义 RewriteCond 和 RewriteRule。这些可以在 .htaccess 中定义。
这个问题已经在
在 htaccess 文件中使用 RewriteMap中得到了解答
If you read the documentation you will see that, in the doc field named 'Context', the RewriteMap directive may be used in the server config or in the virtual host config. It is not permitted in directory or .htaccess - to be clear, the answer is No, it is not still possible to do a rewrite map if all you have access to is .htaccess.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap
The only 'workaround' would be to define a RewriteCond and RewriteRule for every mapping that you need. These can be defined in .htaccess.
This question was already answered in
use RewriteMap in htaccess file