如何删除“cgi-bin” 从我的网址?
我正在嵌入式设备上创建一个小型应用程序,该设备上运行着 boa Web 服务器。 我正在混合纯 HTML 页面和 Perl 脚本创建一个 Web 应用程序,以便与主应用程序交互。 有没有办法隐藏某些页面是从设备上的 cgi-bin 中提供的事实?
我现在拥有的是以下网址。
- http://localhost/home.html
- http://localhost/cgi-bin/config.pl
- http://localhost/cgi-bin/control.pl
- http://localhost/info .html
我非常喜欢的是:
上面的 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.
- http://localhost/home.html
- http://localhost/cgi-bin/config.pl
- http://localhost/cgi-bin/control.pl
- http://localhost/info.html
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,Boa 似乎没有任何类型的 mod_rewrite 选项可用,因此您在重写 URL 方面的能力受到限制。 从 boa 文档 中,您可以选择以下选项:确实有可用的:
重定向、别名和 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
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.
在 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.