regex - Ubuntu 18 Apache .htaccess 使用通配符重写到其他目录 - 美化 URL

标签 regex .htaccess ubuntu mod-rewrite apache2

是否可以创建包含通配符的重写代码?

例如任何请求:

https://eazita.com/live/*.m3u8

重写到以下目录

public_html/live/*/index.m3u8

以下不带通配符的 htaccess 文件工作正常:

RewriteEngine on
RewriteRule ^live/sda425sdf\.m3u8$ live/sda425sdf/index.m3u8 [NC]

但我想要这个带有通配符的:(类似这样的东西,但这个不起作用):

RewriteEngine on
RewriteRule ^live/(.*)\.m3u8$ live/$1/index.m3u8 [NC]

apache 错误日志是这样说的:

[Thu Jan 09 17:56:27.459722 2020] [core:error] [pid 10264] [client 196.62.94.79:55537] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

最佳答案

您可以在站点根目录.htaccess中使用规则:

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}/live/$1/index.m3u8 -f
RewriteRule ^live/([\w-]+)\.m3u8$ live/$1/index.m3u8 [L,NC]

关于regex - Ubuntu 18 Apache .htaccess 使用通配符重写到其他目录 - 美化 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59666027/

相关文章:

.htaccess - 慢: no character set specified in their HTTP headers

c - 为什么这不执行第二个 printf?

php - 如何用破折号替换字符串中的空格 - php

Java正则表达式提取带或不带引号的字段

用于 Javascript 正则表达式和数字的 Javascript 正则表达式

php - 用于检测连续数字的正则表达式 - 不适用于非英语输入

apache - 在 apache localhost 服务器上使用 .htaccess 文件

php - 无法删除 root 上 WordPress 站点的子文件夹中的 codeigniter 的 index.php

node.js - 在 Ubuntu 18.04 上安装 Node 版本 10

ubuntu - net/http : request canceled while waiting for connection (Client. 等待 header 时超时)