【问题标题】:Writing htaccess rewrite rules编写 htaccess 重写规则
【发布时间】:2021-04-10 19:38:51
【问题描述】:

我需要帮助来制定这个 htaccess 重写规则

假设我有这个网址http://test.com/new.php?code=6789767897879&channel=1432

我需要将其设为http://test.com/live/6789767897879/1432.m3u8,其中代码和频道号是可变的

到目前为止,我尝试了这个,但没有找到任何页面。

RewriteEngine On
RewriteBase /
RewriteRule ^/live/(.*)/(.*)?$ /new.php?code=$1&channel=$2

对不起,我是初学者。任何努力都值得赞赏。再次感谢

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting friendly-url


    【解决方案1】:

    您能否尝试使用您展示的示例进行跟踪、编写和测试。请确保在测试 URL 之前清除浏览器缓存。

    RewriteEngine ON
    RewriteRule ^live/([^/]*)/([^.]*)\.m3u8/?$ new.php?code=$1&channel=$2 [NC,L]
    

    【讨论】:

    • new.php 在哪里?谢谢
    • @AhmedIbrahim, I need to make it http://test.com/live/6789767897879/1432.m3u8 where code and channel number are variable 我应该问你:)你没有在你的问题中提到。它究竟应该在哪里?请务必提及。
    • 感谢您的回复,它位于 /var/www/html 中的默认 apache 目录。它在 .htaccess 文件的同一目录中
    • @AhmedIbrahim,你能不能现在试试我编辑的代码,让我知道它是怎么回事?
    • 像魅力一样工作。你是最棒的!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多