如何删除“cgi-bin” 从我的网址?

发布于 2024-07-12 09:46:38 字数 1419 浏览 7 评论 0原文

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

我现在拥有的是以下网址。

我非常喜欢的是:

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

我已经在 Google 上搜索过这个内容,但正如你可以想象的那样,我得到了一页又一页的 URL 中带有“cgi-bin”的搜索结果。 我希望这里有人以前做过这件事。

编辑:我应该提到,我知道如何通过在我的网络根目录中创建单独的文件夹(所有文件夹都包含index.html页面)来对纯HTML页面执行此操作。 我的问题是让这种类型的解决方案与 cgi-bin 目录中的 .pl 或 .cgi 文件一起使用。

I'm creating a small application on an embedded device that has a boa web server running on it. I'm creating a web application in a mixture of plain HTML pages and Perl scripts to interface with the main application. Is there a way to hide the fact that some of the pages are being served out of the cgi-bin on the device?

What I have now are the following URLs.

What I would greatly prefer would be:

with the above URLs taking me to the appropriate index.html or index.pl document. Is there some combination of file structure and server settings that will enable this behavior?

I've searched Google for this, but as you can imagine I'm getting pages and pages of search results with "cgi-bin" in the URL. I'm hoping someone here has done this before.

EDIT: I should mention that I know how to do this for plain HTML pages by making separate folders in my web root, all with index.html pages. My problem is in getting this type of solution to work with .pl or .cgi files in the cgi-bin directory.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

洛阳烟雨空心柳 2024-07-19 09:46:38

不幸的是,Boa 似乎没有任何类型的 mod_rewrite 选项可用,因此您在重写 URL 方面的能力受到限制。 从 boa 文档 中,您可以选择以下选项:确实有可用的:

重定向、别名和 ScriptAlias

重定向、别名和 ScriptAlias 全部
具有相同的语义——它们匹配
请求的开始并采取
采取适当的行动。 使用重定向用于
其他服务器,相同的别名
服务器和 ScriptAlias 来启用
脚本执行的目录。

重定向

允许您告诉客户您的文档中曾经存在的信息
服务器的命名空间,但不
不再了。 这可以让你告诉
客户在哪里寻找
重新定位的文档。

别名

将一条路径别名为另一条路径。 当然,文件中的符号链接
系统也工作正常。

脚本别名

将虚拟路径映射到用于服务脚本的目录。

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

Boa unfortunately doesn't appear to have any type of mod_rewrite options available to it, so you're limited in what you can do to rewrite a URL. From the boa docs here are the options you do have available:

Redirect, Alias, and ScriptAlias

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.

Based on that you might try ScriptAlias or Alias, or even a symlink to a "nicer" URL. Unfortunately since I don't have Boa available here I can't test the options to tell you more specifically what to try.

命硬 2024-07-19 09:46:38

在 apache 中,使用 mod_rewrite 会很简单,但 boa 有点不同。 这里发生了几个不同的问题。 对于 .html 文件,请确保 boa.conf 中有以下行:

DirectoryIndex /index.html

然后,在访问根目录时将检索任何名为 index.html 的文件。 因此,如果您的根目录是 /htdocs,那么 /htdocs/index.html 和 /htdocs/info/index.html 应该可以解决这些问题。

对于其他脚本,您需要添加以下行:

AddType application/x-httpd-cgi pl

这应该让 perl 执行为 CGI 在任何地方执行。 然后就是确保 boa 知道它们是索引文件。 您也许可以使用重定向或别名指令来克服其中的一些问题。

In apache, this would be simple with mod_rewrite, but boa is a little different. You've got a couple of different issues going on here. For the .html files make sure you have the following line in boa.conf:

DirectoryIndex /index.html

Then any file that is called index.html will be retrieved when hitting the root. So if your root directory is /htdocs then makings /htdocs/index.html and /htdocs/info/index.html should take care of those problems.

For your other scripts, you'll need to add the following line:

AddType application/x-httpd-cgi pl

That should let perl execute as CGIs execute everywhere. Then it's a matter of making sure that boa knows they're the index files. You may be able to get over some of that using Redirect or Alias directives.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文