是否可以创建包含通配符的重写代码?
例如任何请求:
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/