Apache的301重定向和preserving发布数据 [英] Apache 301 Redirect and preserving post data

查看:258
本文介绍了Apache的301重定向和preserving发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现SEO的URL重定向到负责处理所有URL建设和内容提供网站的根目录下的redirect.cfm。

I have implemented SEO URLs using Apache 301 redirects to a 'redirect.cfm' in the root of the website which handles all URL building and content delivering.

POST数据301重定向过程中丢失。

Post data is lost during a 301 redirect.

无法找到一个解决方案,到目前为止,已经尝试排除法后从重写 - 最坏的情况下,我们可以使用旧型网址后方法

Unable to find a solution so far, have tried excluding post method from rewrites - worst case scenario we could use the old type URLs for post methods.

有什么可以做的?

感谢

推荐答案

POST数据将被丢弃在重定向作为客户端将执行一个GET请求由301段指定的URL。

POST data is discarded on redirect as a client will perform a GET request to the URL specified by the 301. Period.

唯一的选择是转换的POST参数,以获得参数和粘性它们放到你重定向到URL的结尾。这不能在.htaccess文件重写来完成。

The only option is to convert the POST parameters to GET parameters and tack them onto the end of the URL you're redirecting to. This cannot be done in a .htaccess file rewrite.

一个选项是赶上POST请求的URL重定向和将其传递给一个页面来处理重定向。你需要做code参数换位然后发出后附加新的URL这样的参数重定向头。

One option is to catch POST requests to the url to be redirected and pass it off to a page to handle the redirect. You'd need to do the transposition of the parameters in code then issue the redirect header with the parameter appended new url that way.

更新:由于在评论中指出了这个答案,如果你重定向到另一个网址指定POST参数和URL也被存取,而不paramters(或PARAMS是可变的),你应该指定一个链接到规范的网址的页面。

Update: As pointed out in the comments to this answer, if you do redirect to another URL specifying POST parameters and that URL is also accessed without paramters (or the params are variable), you should specify a link to the canonical URL for the page.

说出POST形式重定向换位到以下GET资源:

Say the POST form redirects transposed to the following GET resource:

   http://www.example.com/finalpage.php?form_data_1=123&form_data_2=666

您将这个链接记录添加到页面的头部分:

You would add this link record to the head section of the page:

   <link rel="canonical" href="http://www.example.com/finalpage.php" />

这将确保所有的搜索引擎优化的价值将给予 http://www.example.com/finalpage.php 并避免可能出现的问题与重复的内容。

This would ensure all SEO value would be given to http://www.example.com/finalpage.php and avoid possible issues with duplicate content.

这篇关于Apache的301重定向和preserving发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆