URL 重写以删除参数但发送它
我目前在我的网站上使用 register.php?referal=gamestand ,以便当用户通过推荐网站访问我的网站时,我可以跟踪有多少玩家从该地方注册。
referal=gamestand 将在注册过程中使用 echo $_GET['code'] 自动填写输入文本字段;
问题是...在 Google 上,我有大量来自这些推荐的链接,我想将它们 301 到我的 register.php 页面,以将 SEO 分数合并为一个,并最终删除这些愚蠢的 register.php?code=gamestand 风格来自谷歌的链接。
我有这个重写规则...它删除了 ?code=gamestand 位,但它实际上并没有传递参数,可能是因为它重定向并且不发送任何内容?
RewriteCond %{QUERY_STRING} ^(.*)code(.*)$
RewriteRule ^(.*)$ http://localhost/mywebsite/httpdocs/register.php? [R=301,L]
它将把 register.php?code=gamestand 更改为 register.php 但正如我所说, $_GET['code'] 现在是空的,我回到了第一个!
如果有人知道任何事情,请提供任何帮助...谢谢!多姆
I currently use register.php?referal=gamestand on my website so that when the user visits my website through the referal website, I can track how many players have registered from that place.
referal=gamestand will automatically fill in an input textfield within the registration process using echo $_GET['code'];
The problem is... on Google I have loads of links from these referals and I'd like to 301 them to my register.php page to merge the SEO score into one and eventually remove these silly register.php?code=gamestand style links from google.
I've got this rewrite rule... which removes the ?code=gamestand bit, but it doesn't actually pass the parameter, probably because it's redirecting and sending nothing?
RewriteCond %{QUERY_STRING} ^(.*)code(.*)$
RewriteRule ^(.*)$ http://localhost/mywebsite/httpdocs/register.php? [R=301,L]
it will change register.php?code=gamestand into register.php but as I said, $_GET['code'] is now empty and I'm back to square one!
Appreciate any help if anyone knows anything... Thanks! Dom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将引荐来源网址存储在会话变量中,然后重定向到没有代码的
register.php
。您的 URL 将不再包含该代码,但可以通过会话访问它。You could store the referrer in a session variable, then redirect to
register.php
without the code. Your URL won't contain the code any more, but it's available via the session.将这些 URL 重定向到同一 URL 可能不会将您的 SEO 得分合并为一个。你现在的方法很好,不要乱用。
Redirecting these Urls to the same Url probably won't merge your SEO score into one. Your current method is fine, don't mess with it.