如何在Apache中重定向?
这应该是一个简单的问题,但我不明白这一点。我有一台计算机上运行,以从本地网络访问的网页。我想重定向下运行CGI回到我的 /var/www/index.html /
文件脚本的结果。我试图把一个重定向线在我的/ etc / apache2的/ apache2.conf``没有工作,所以我尝试了一个更简单的任务:
This should be a simple issue but I can't figure this out. I have a webpage running on a machine to access from the local network. I want to redirect the results of scripts run under cgi back to my /var/www/index.html/
file. I tried to place a redirect line in my /etc/apache2/apache2.conf`` that didn't work so I tried an even simpler task:
redirect permanent /var/www/index.html http://www.google.com
和甚至没有这个工作。
And not even this worked.
我在做什么错了?
我在Ubuntu的机器上运行这一点。
I'm running this on an Ubuntu machine.
编辑:
当我重新启动服务器这是添加到我的错误日志:
This is added to my error log when I restart the server:
[Sat Jun 16 17:26:36 2012] [notice] caught SIGTERM, shutting down | * Restarting web server apache2
[Sat Jun 16 17:26:36 2012] [notice] Apache/2.2.22 (Ubuntu) configured -- \|apache2: Could not reliably determine the server's fully qualified domain \
resuming normal operations
编辑:解决和一个新的问题
Solved and a new problem
我已成功地重定向网页,以谷歌,现在我想要做的实际重定向。我已经加入这个我 apache2.conf
文件
I have managed to redirect the webpage to google and now I want to do the actual redirect. I have added this to my apache2.conf
file
Redirect permanent /cgi-bin/file.cgi /index.html
和删除previous文件。现在,该文件被重定向到谷歌,而不是回到我的家文件...
And removed the previous file. The file now is redirected to google and not back to my home file...
这是怎么回事?
据我所知重定向是不是基于'文件',但在一个网址。
As far as I know the redirect is not based on a 'file' but on an URL.
所以你的情况,你应该尝试:
So in your case you should try:
Redirect permanent /index.html http://www.google.com
请参阅Apache文档以了解更多信息:的http:// httpd的。 apache.org/docs/2.0/mod/mod_alias.html#Redirect
您也可以尝试mod_rewrite的,但请记住,它适用于传入的请求/网址不是文件上的文件系统。
You could also try mod_rewrite, but keep in mind it works on incoming requests/URLs not on files on the filesystem.
PS。确保你重新加载您的配置更改后。
ps. Make sure you reload you configuration after your changes.