.htaccess重定向匹配是否可以从url中删除部分?
我想重定向此url:.htaccess重定向匹配是否可以从url中删除部分?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我想重定向此url: domain.asd/category/node123/attachment/file123 对于这一点: domain.asd/category/node123 从末端移除附件/fn1aa 只有节点123和文件123是动态的 下面的代码可以工作,但它是有效的、安全的和资源友好的 RedirectMatch permanent category(.*)attachment /category/$1 欢迎任何推荐。thx.试试: RedirectMatch perman
domain.asd/category/node123/attachment/file123
对于这一点:
domain.asd/category/node123
从末端移除附件/fn1aa
只有节点123和文件123是动态的
下面的代码可以工作,但它是有效的、安全的和资源友好的
RedirectMatch permanent category(.*)attachment /category/$1
欢迎任何推荐。thx.试试:
RedirectMatch permanent ^/category/([^/]+)/attachment /category/$1
它更严格,不会复制前斜杠(/
)。您的正则表达式也将匹配以下内容:
domain.asd/foo/something/category/a/b/c/d/e/f/some-attachment
通过重定向到:
/category//a/b/c/d/e/f/some-
这可能不是你想做的。它的安全性和资源友好性与使用htaccess文件一样(与将其放在vhost配置中相比,这对性能有轻微的影响)