【问题标题】:Htaccess 301 redirect: looking for specific variableHtaccess 301 重定向:寻找特定变量
【发布时间】:2010-12-24 01:51:29
【问题描述】:

我现在有这个:

重写规则 ^/?word/(.*) /display.php?mid=$1 [L,R=301]

这会变成:http://testpp.peoplepulse.com.au/word/testvar 变成http://testpp.peoplepulse.com.au/display.php?mid=testvar

如何搜索 16 个字符/数字的字符串而不是单词“word”?

【问题讨论】:

    标签: regex .htaccess redirect


    【解决方案1】:
    RewriteRule ^[a-zA-Z0-9]{16}]/(.*) display.php?mid=$1 [L,R=301]
    

    【讨论】:

      【解决方案2】:

      如果你的字符是指字母:

      RewriteRule ^[a-z0-9]{16}/([^/]*) /display.php?mid=$1 [NC,L,R=301]
      

      如果你的意思是“任何字符”:

      RewriteRule ^[^/]{16}/([^/]*) /display.php?mid=$1 [NC,L,R=301]
      

      【讨论】:

      • 所以它可以使用:RewriteRule ^([a-zA-Z0-9_-]+)/(.*) /display.php?mid=$1 [L,R=301] -但是在将字符串输入网址后需要一个斜杠...有人知道如何处理尾随和非尾随吗?
      猜你喜欢
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-06
      • 2012-12-08
      • 2013-09-19
      • 2011-12-30
      相关资源
      最近更新 更多