Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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 在Apache中使用正则表达式重写URL时,我可以在新URL中使用HTML标题标记吗?_Regex_Apache_Mod Rewrite_Url Rewriting - Fatal编程技术网

Regex 在Apache中使用正则表达式重写URL时,我可以在新URL中使用HTML标题标记吗?

Regex 在Apache中使用正则表达式重写URL时,我可以在新URL中使用HTML标题标记吗?,regex,apache,mod-rewrite,url-rewriting,Regex,Apache,Mod Rewrite,Url Rewriting,我们有一些时髦的URL,如下所示: RewriteRule ^product-category/([0-9]+)/?$ /cs/Satellite?c=TA_Parent&childpagename=Taconic%2FTA_Parent%2FProductModel&cid=$1&pagename=GST%2FDispatcher [QSA,NC,L] (some domain.com)/cs/Satellite?c=TA_Parent&childpagename=T

我们有一些时髦的URL,如下所示:

RewriteRule ^product-category/([0-9]+)/?$ /cs/Satellite?c=TA_Parent&childpagename=Taconic%2FTA_Parent%2FProductModel&cid=$1&pagename=GST%2FDispatcher [QSA,NC,L]
(some domain.com)/cs/Satellite?c=TA_Parent&childpagename=Taconic%2FTA_Parent%2FProductModel&cid=1347209502190&pagename=GST%2FDispatcher

我想匹配这个:

/cs/Satellite?c=TA_父项和子项PageName=Taconic%2FTA_父项%2ProductModel&cid=

并将其替换为一些文本(例如,
/product category/
),然后使用

1347209502190

并删除

&pagename=GST%2F调度程序

用HTML中的页面标题替换
1347209502190

所以-我最终要么这样

(some domain.com)/产品类别/1347209502190

还是这个

(some domain.com)/产品类别/产品名称


这是否可能?如果需要从HTML中提取产品名称?

您可能需要这样的重写规则:

RewriteRule ^product-category/([0-9]+)/?$ /cs/Satellite?c=TA_Parent&childpagename=Taconic%2FTA_Parent%2FProductModel&cid=$1&pagename=GST%2FDispatcher [QSA,NC,L]
这将查找对product category/[product ID]的请求,并默默地重写它,以实际请求服务器提供更长的URL。较长URL中的
$1
插入正则表达式中的匹配项(
([0-9]+)

如果您还想将其替换为产品名称,您将需要一组更长的重写规则来匹配您希望放入站点的Apache
.conf
文件中的每个产品名称,而不是
.htaccess
,因为
.htaccess
文件将与启动时加载站点配置的每个请求一起解析。如果可能经常添加和删除产品,那么文件维护可能会成为一个问题