Mod rewrite 如何使用重定向匹配或重写规则编写规则

Mod rewrite 如何使用重定向匹配或重写规则编写规则,mod-rewrite,Mod Rewrite,我花了这么多时间让下面的东西工作。但看起来它不起作用了 我需要将用户重定向到: /webcenter/portal/MyPortal 当他们尝试访问时: /webcenter/ /webcenter/portal /webcenter/portal/home 我在OHS服务器的配置文件中尝试了RedirectMatch和RewriteRule,但运气不佳 RewriteRule ^webcenter$ http://portal.abc.com/webcenter/portal/MyPor

我花了这么多时间让下面的东西工作。但看起来它不起作用了

我需要将用户重定向到:

/webcenter/portal/MyPortal
当他们尝试访问时:

/webcenter/ 
/webcenter/portal
/webcenter/portal/home
我在OHS服务器的配置文件中尝试了RedirectMatch和RewriteRule,但运气不佳

RewriteRule ^webcenter$ http://portal.abc.com/webcenter/portal/MyPortal [L]
你能帮我一下吗。

这应该可以:

RewriteRule ^/webcenter/(portal|portal/home)?$ http://portal.abc.com/webcenter/portal/MyPortal [R=301,L]

将其放在您已有的规则之后。

您在.htaccess文件或您要放置规则的任何其他规则中还有其他内容吗?您是直接将规则放在配置文件上还是放在.htaccess文件上?我已经有了这个规则。RedirectMatch^/$我正在OHS home的moduleconf文件夹下的自定义配置文件中放置规则。您好,这似乎对我有用。非常感谢您的帮助。您好@user2961454,我们有一些类似的要求,我正在做的是在/directory的httpd.conf文件中的RewriteRule.*上添加RewriteEngine,但它没有达到我的期望。请您分享您的方法和您为使其发挥作用所做的输入