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/

相关文章:

.htaccess 重定向删除 php 并重定向到 https 和非 www

.htaccess 和 mod-rewrite

apache - 用于测试目的的 SSL 证书

java - 尝试比较两个对象并提取包含它们差异的第三个对象

php - 防止直接访问 mp3/wav 文件,同时允许 Flash 播放器使用 .htaccess(或 PHP)访问它们

apache - 带有 Apache HTTPD 的负载均衡器

regex - .htaccess 重定向 : convert path to GET variables?

.htaccess - 301 将整个网站重定向到单个页面

apache - 为什么RewriteCond%{REQUEST_FILENAME}!-d是必需的?

apache - 重写规则(静态内容除外)