web-applications - 如何从我的 URL 中删除 "cgi-bin"?

标签 web-applications url-rewriting cgi cgi-bin

我正在具有 boa 的嵌入式设备上创建一个小型应用程序。在其上运行的 Web 服务器。我正在创建一个混合了普通 HTML 页面和 Perl 脚本的 Web 应用程序,以与主应用程序交互。有没有办法隐藏某些页面是从设备上的 cgi-bin 提供的事实?

我现在拥有的是以下 URL。

  • http://localhost/home.html
  • http://localhost/cgi-bin/config.pl
  • http://localhost/cgi-bin/control.pl
  • http://localhost/info.html

  • 我非常喜欢的是:
  • http://localhost/
  • http://localhost/config/
  • http://localhost/control/
  • http://localhost/info/

  • 上面的 URL 将我带到相应的 index.html 或 index.pl 文档。是否存在文件结构和服务器设置的某种组合可以启用此行为?

    我已经在 Google 上搜索过这个,但正如您所想象的那样,我正在获取 URL 中带有“cgi-bin”的搜索结果页面。我希望这里有人以前做过。

    编辑:我应该提到,我知道如何通过在我的 web 根目录中创建单独的文件夹来为纯 HTML 页面执行此操作,所有这些文件夹都包含 index.html 页面。我的问题是让这种类型的解决方案可以处理 cgi-bin 目录中的 .pl 或 .cgi 文件。

    最佳答案

    不幸的是,Boa 似乎没有任何可用的 mod_rewrite 选项,因此您在重写 URL 时可以做的事情受到限制。来自 boa docs以下是您可以使用的选项:

    重定向、别名和脚本别名

    Redirect, Alias, and ScriptAlias all have the same semantics -- they match the beginning of a request and take appropriate action. Use Redirect for other servers, Alias for the same server, and ScriptAlias to enable directories for script execution.

    Redirect

    allows you to tell clients about documents which used to exist in your server's namespace, but do not anymore. This allows you tell the clients where to look for the relocated document.

    Alias

    aliases one path to another. Of course, symbolic links in the file system work fine too.

    ScriptAlias

    maps a virtual path to a directory for serving scripts.



    基于此,您可以尝试使用 ScriptAlias 或 Alias,甚至是指向“更好” URL 的符号链接(symbolic link)。不幸的是,由于我这里没有可用的 Boa,我无法测试这些选项来更具体地告诉您要尝试什么。

    关于web-applications - 如何从我的 URL 中删除 "cgi-bin"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/466448/

    相关文章:

    apache - 如何禁用将尾部斜杠添加到 Apache 中的目录名称的 301 重定向

    javascript - Angular 斜线被编码

    coldfusion - 检索 HTTP header 值

    Java URLrewrite 过滤器 - 传递参数

    无法在cgi中执行外部命令

    perl - 如何使用 Perl 将客户端从一个 CGI 页面重定向到另一个页面?

    linux - 自动构建 c/c++ 程序的 Web 界面?

    asp.net - 多线程环境下的文件访问策略(Web App)

    javascript - 使用 Constant 组件在 React JS 中设置主要组件的样式

    java - Java中如何查找哪个用户正在使用某个端口