Regex 如何编写此URL重写规则来构造不需要的内容?

Regex 如何编写此URL重写规则来构造不需要的内容?,regex,apache,url-rewriting,Regex,Apache,Url Rewriting,Iam使用apache mod_rewrite重定向一些URL。我可以访问一些URL,但我的规则中没有一条能够解决这个问题 并将其重定向到 您可以将此规则用作站点root.htaccess或Apache配置中的第一条规则: # this goes in httpd.conf AllowEncodedSlashes On RewriteEngine On RewriteRule ^(/?mome/[^/]+)/.+$ /$1 [L,NC,R=301,NE] 这将匹配以/mome开头的任何U

Iam使用apache mod_rewrite重定向一些URL。我可以访问一些URL,但我的规则中没有一条能够解决这个问题

并将其重定向到


您可以将此规则用作站点root.htaccess或Apache配置中的第一条规则:

# this goes in httpd.conf
AllowEncodedSlashes On

RewriteEngine On

RewriteRule ^(/?mome/[^/]+)/.+$ /$1 [L,NC,R=301,NE]

这将匹配以
/mome
开头的任何URI,并将截断第二路径组件之后的任何内容。

不起作用,它表示“在此服务器上找不到请求的URL/mome/GIS Endo//home/GIS%20Endo/”,因此它不会截断字符串。不知道字符串中的编码值是否会导致任何问题。实际上它工作正常,但我必须启用AllowEncodedsLash。谢谢