apache - 编写 htaccess 重写规则

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

我需要帮助制定此 htaccess 重写规则
假设我有这个网址 http://test.com/new.php?code=6789767897879&channel=1432
我需要成功 http://test.com/live/6789767897879/1432.m3u8其中代码和 channel 号是可变的
到目前为止,我没有运气就尝试过这个,但它一直没有给我找到任何页面。

RewriteEngine On
RewriteBase /
RewriteRule ^/live/(.*)/(.*)?$ /new.php?code=$1&channel=$2
对不起,我是初学者。任何努力都值得赞赏。再次感谢

最佳答案

您能否尝试使用您显示的样本进行以下、编写和测试。请确保在测试 URL 之前清除浏览器缓存。

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

关于apache - 编写 htaccess 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65572377/

相关文章:

javascript - Steam 发布请求 - 无法加载资源 : the server responded with a status of 400 (Bad Request)

nginx - Nginx 中的多站点 WordPress 重写规则

.htaccess - 如何让 RewriteRule (.htaccess) 的 [L] 标志真正起作用?

apache - Apache 301重定向和保留发布数据

php - 如何使用 php 中的 pid 终止 linux 进程?

apache - 为 Varnish 配置更改 httpd 配置上的监听端口

apache - htaccess 重写传递两个变量或一个变量是否可用?

apache - 有人可以帮我避免内部服务器错误吗? htaccess | apache2ctl |回溯

apache - 使用 htaccess 创建日志文件

regex - 用 htaccess (php) 重写 URL