Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 使用mod rewrite和通配符动态创建URL_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex 使用mod rewrite和通配符动态创建URL

Regex 使用mod rewrite和通配符动态创建URL,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我有以下资料: RewriteRule ^tribute-acts/([^/.]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC] 哪些变化: http://mysite.com/entertainment/act-view.html?act_name=elvis 致: 很好,但是如果部分是动态生成的,并且每个链接都不同,那该怎么办?因此,无限的可能性 我是否可以使用通配符而不是act/ 我使用(.*)尝试了以下操作,但没有成功

我有以下资料:

RewriteRule ^tribute-acts/([^/.]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]
哪些变化:

http://mysite.com/entertainment/act-view.html?act_name=elvis
致:

很好,但是如果
部分是动态生成的,并且每个链接都不同,那该怎么办?因此,无限的可能性

我是否可以使用通配符而不是
act/

我使用
(.*)
尝试了以下操作,但没有成功:

RewriteRule ^(.*)/([^/.]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA,NC]
您可以尝试以下规则:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]+/([^/]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA]
您可以尝试以下规则:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]+/([^/]*)/?$ /entertainment/act-view.html?act_name=$1 [L,QSA]

谢谢,但不起作用,如果我尝试,例如mysite.com/hello/elvis,它仍然将hello视为act_name变量,而不是elvisOh对不起,我的错误,请立即查看编辑的答案。我不需要对路径的第一部分进行分组。谢谢,但不起作用,如果我尝试,例如mysite.com/hello/elvis,它仍然将hello视为act_name变量,而不是elvisOh抱歉,我的错误,请立即查看编辑的答案。我不需要对路径的第一部分进行分组。