【问题标题】:hiding query string parameters htaccess隐藏查询字符串参数 htaccess
【发布时间】:2012-11-08 08:01:13
【问题描述】:

您好,我想问一下如何使用 .htaccess mod_write 将 http://abc.tk/comments.php?post_referrel_id=16 转换为 http://abc.tk/comments.php?post_referrel_id/16 表示用户看到此链接 abc.tk/cmets.php?post_referrel_id/16 当他单击具有源的超链接时 abc.tk/cmets.php?post_referrel_id=16

【问题讨论】:

  • 你不能按你的要求去做。但是您可以将 URL 转换为 http://abc.tk/comments.php/post_referrel_id/16...
  • 你能告诉我兄弟是怎么做到的......

标签: php mysql .htaccess querystringparameter


【解决方案1】:

您需要研究,先生。 检查这个简单tuto

对于您的提示,请勿在重写的网址中使用?

这里有一个快速代码(在重写后的网址中使用?

RewriteEngine on
RewriteRule ^comment.php?post_referrel_id/([0-9]+)$ comment.php?post_referrel_id=$1

【讨论】:

    【解决方案2】:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^comments.php?post_referrel_id/(.*)$ comments.php/post_referrel_id=$1 [L,QSA]
    

    您可能需要添加从一个表单到另一个表单的重定向。上面的代码只是告诉服务器 /16 和 =16 是一样的

    【讨论】:

      【解决方案3】:

      使用这些代码行:

      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^abc.tk
      RewriteRule ^comments.php?post_referrel_id=([0-9]+)$ comments.php?post_referrel_id/$1 [R=301,L]
      

      这将被重定向 comments.php?post_referrel_id=16comments.php?post_referrel_id/16

      【讨论】:

      • 我哥这不工作.....不知道为什么.....你能解释一下上面的代码
      • 为了使用重写模式,你的 apache mod_rewrite 模块应该被启用。这些代码告诉 apache 将每个包含 abc.tk/cmets.php?post_referrel_id=[numeric] 的 url 重定向到 abc.tk/cmets.php?post_referrel_id/[numeric]
      • 嘿兄弟,我正在使用 000webhost 服务器......并且 mod_write 已启用......但不知道为什么这段代码不起作用............跨度>
      • 我不知道为什么这对你不起作用。看看这个:corz.org/serv/tricks/htaccess2.php
      • 我以前看过这个页面.......根据它使用了命令,但没有成功
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 2012-09-25
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      相关资源
      最近更新 更多