Ben*_*yer 4 apache .htaccess redirect http http-status-code-410
我们有一个正在关门的客户.我们希望将发往其域的所有流量重定向到新页面index.html,并在_img子目录中包含一些图像.(该页面解释了发生了什么,当前客户对当前订单的期望等等)
我已经阅读过关于可能使用HTTP 410 Gone作为技术上向机器人解释的最佳方式,该网站不在那里,没有回来而且没有提供转发地址.在.htaccess文件中执行此操作的最佳方法是什么,并将用户定向到新的index.html?
Gum*_*mbo 10
你可以使用mod_rewrite.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.html$ index.html [L,R=410]
Run Code Online (Sandbox Code Playgroud)
此规则将对不存在的文件的请求重写为index.html,并将410状态代码与响应一起发送.但这需要Apache 2,因为R = 4xx仅在Apache 2之后可用.