0

我的旧网站有很多使用 cgi-bin 目录的 url,例如:www.website.com/cgi-bin/etc?123

现在该站点位于运行 wordpress 的新服务器上,我想将其重定向到:www.website.com/etc/123

问题是我得到了 404 没有被 wordpress 处理的错误,甚至创建一个目录 cgi-bin 也会做同样的事情。

我不太确定是否可以通过 .htaccess 执行此操作,或者这与 PHP.ini 设置甚至 apache 有关吗?

如何 URL 重定向 cgi-bin?由于不再使用 cgi-bin,现在它正在通过 wordpress 处理。

谢谢

4

2 回答 2

0

您可以创建从 cgi-bin 到新目标的符号链接:

ln -s cgi-bin etc

查看“ln”的手册页以全面了解该命令。如果您没有 shell 访问权限,您的 Web 服务器前端(例如 cPanel)可能会创建此类链接。

也就是说,考虑到 cgi-bin 的特殊意义和 Web 服务器的处理,cgi-bin 的重定向可能不是一个好的长期解决方案。在更新 Wordpress 中的路径时使用重定向来保持运行,然后删除重定向。

于 2010-09-21T00:25:25.043 回答
0

如果您有可用的mod_rewrite并且我已经正确理解了您想要的内容,您可以使用以下规则集将 cgi-bin URL 重定向到新 URL:

RewriteEngine On

# Check the query string for a number (you might need to adjust
# the regex to match your data appropriately)
RewriteCond %{QUERY_STRING} ^(\d+)$
# Perform the redirect to the new URL if the current URL starts
# with cgi-bin/
RewriteRule ^cgi-bin/(.*)$ /$1/%1? [R=301,L]
于 2010-09-21T01:06:41.123 回答