【问题标题】:.htaccess Rewrite an url with arguments in gif url.htaccess 用 gif url 中的参数重写 url
【发布时间】:2015-06-08 16:35:37
【问题描述】:

经过一些研究,我仍然无法找到适合我的解决方案。

现在我有一个这样的网址:

--> http://www.localhost.com/images/values-lock/countdown-timer.php?time=201504051144

我想重写并在浏览器中显示这个 url,并有可能获得上面的时间参数:

--> http://www.localhost.com/201504051144/timer.gif

实际上我的最后一次尝试是这样的:

--- .htaccess ---

  RewriteEngine On
   RewriteBase /images/values-locked/
   RewriteRule ^([a-zA-Z])?([a-zA-Z])=([0-9]+)$ $1/timer.gif [QSA]

我还不习惯重写 url 方式,但仍在寻找文档和主题。

感谢您的考虑。

【问题讨论】:

    标签: php .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    这应该可行:

    RewriteEngine On
    RewriteRule ^([^/]*)/timer\.gif$ /images/values-lock/countdown-timer.php?time=$1 [L]
    

    【讨论】:

      【解决方案2】:

      你可以试试这个

       RewriteEngine On
       RewriteBase /images/values-lock/
       RewriteRule ^([0-9]+)/timer\.gif/?$ /images/values-lock/countdown-timer.php?time=$1 [QSA,L]
      

      【讨论】:

        【解决方案3】:

        您可以在 DOCUMENT_ROOT/.htaccess 文件中使用此代码:

        RewriteEngine On
        RewriteBase /
        
        RewriteCond %{THE_REQUEST} /images/values-lock/countdown-timer\.php\?time=([^\s&]+) [NC]
        RewriteRule ^ %1/timer.gif? [R=302,L,NE]
        
        RewriteRule ^([^/]+)/timer\.gif$ images/values-lock/countdown-timer.php?time=$1 [L,QSA,NC]
        

        【讨论】:

        • 谢谢大家帮助我,我解决了我的问题 :)
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-16
        • 1970-01-01
        • 2017-04-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多