Apache重写规则 – 删除URL中的“/”

我需要一个重写规则为Apache重写url:

http://saftsack.fs.uni-bayreuth.de/~dun3/archives/it/programming/fast-dynamic-property-access-using-reflection-emit/33.html

http://saftsack.fs.uni-bayreuth.de/~dun3/archives/fast-dynamic-property-access-using-reflection-emit/33.html

所以,我需要删除“archives”和last /之间的所有/部分,保留/之前的部分和/之后的部分。

像这样的东西应该做你想要的:

RewriteRule ^(/~dun3/archives/).+?/([^/]+/[^/]+)$ $1$2 [L,R=301] 

(最后的R = 301部分发送一个HTTP 301 Moved Permanently头文件,我认为这是你想要做的,但是如果没有,你可以简单地省略那部分。)

 RewriteRule ^(.*?)/(.*?)/.*/(.*?)/(.*?)$ $1/$2/$3/$4