如何使用Regex在.htaccess中编写重定向规则

时间:2021-07-16 10:38:03

can someone tell me how to write redirection rule using regex in .htaccess file. I want

谁能告诉我如何在.htaccess文件中使用正则表达式编写重定向规则。我想要

www.example.com/healthcare/practitioner/nikky.23 

to be redirectd to

被重定向到

www.example.com/healthcare/practitioner/#/nikky.23

Note that last parameter after '/' i.e nikky.23 can change in different cases. Please help.

请注意,'/'即nikky.23之后的最后一个参数可以在不同情况下改变。请帮忙。

1 个解决方案

#1


0  

Try with RewriteRule:

尝试使用RewriteRule:

RewriteRule (healthcare/practitioner/).* $1

If you want the last parameter to be without further slashes:

如果您希望最后一个参数没有进一步的斜杠:

RewriteRule (healthcare/practitioner/)[^/]*$ $1

#1


0  

Try with RewriteRule:

尝试使用RewriteRule:

RewriteRule (healthcare/practitioner/).* $1

If you want the last parameter to be without further slashes:

如果您希望最后一个参数没有进一步的斜杠:

RewriteRule (healthcare/practitioner/)[^/]*$ $1