gpt4 book ai didi

linux - 如何配置 apache 服务器以发送 301 代码作为响应

转载 作者:太空宇宙 更新时间:2023-11-04 11:39:50 25 4
gpt4 key购买 nike

我想配置 Apache 以实现永久移动响应。

我对此的想法是——

1) 我需要在 httpaccess 中添加以下行重定向 301/e/301 我可以将此行放在 httpaccess 文件中的任何位置吗?

2) 然后我必须有一个页面(假设它是 redirect.html,)放入/var/www/html/project_name.

将在重定向时显示(将显示 301 代码)。

现在我想要的是,如果有人访问页面 example.html ,它需要被重定向到 redirect.html 。

我需要在何处添加什么语法,或者需要在 httpd 或其他不同的 Apache 文件中进行哪些更改。

以上两点有误请指正

非常感谢。

最佳答案

找到了解决方案- 我们可以使用重定向目录或通过在 httpdaccess.conf 中重写引擎来做到这一点

为了通过重写引擎在 conf 文件中添加以下行来做到这一点

重写引擎开启

302代码

重写规则/.* http://www.new_server.com/ [R]

for 301 - 将您的一侧永久重定向到另一侧

RewriteRule permanent/.* http://www.new_server.com/ [R]

页面

重定向/old.html http://ww.new_server.com/new.html

永久重定向/old.html http://www.new_server.com/new.html

关于linux - 如何配置 apache 服务器以发送 301 代码作为响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4461844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com