I'm trying to create a regex that takes a filename like:
/cloud-support/filename.html#pagesection
and redirects it to:
/cloud-platform/filename#pagesection
Could anyone advise how to do this?
Currently I've got part-way there, with:
"^/cloud-support/(.*)$" => "/cloud-platform/$1",
which redirects the directory okay - but still has a superfluous .html
.
Could I just match for a literal .html
with optional #
? How would I do that?
Thanks.
"^/cloud-support/(\w+).html(.*)" => "/cloud-platform/$1$2"
这样的事情行吗?
"^/cloud-support/([^.]+)[^#]*(.*)$" => "/cloud-platform/$1$2"
Can you try the regex
"^/cloud-support/(.*)\.html(#.*)?$"
The \\.html
part matches .html
while (#.*)?
allows an optional #
plus something.
Maybe something like this:
"^/cloud-support/(.*?)(\.html)?(#.+)$" => "/cloud-platform/$1$3"
where the first group is a non-greedy match (.*?)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.