2013-03-11 56 views
0

我有很多包含在最后一个13位数字代码的URL,看起来像......htaccess的装饰数字

http://www.example.com/a-test-title-1/1579845887463/ 
http://www.example.com/a-test-title-2/2356668749876/ 
http://www.example.com/a-test-title-3/5689874598235/ 

我想删除这些号码,网址看起来像......

http://www.example.com/a-test-title-1/ 
http://www.example.com/a-test-title-2/ 
http://www.example.com/a-test-title-3/ 

我试过这个在我的htaccess文件RewriteRule [0-9]{10,15} $1 [R=301,L]但它不工作,我不知道该怎么办?

任何人有任何想法?

感谢,

詹姆斯

回答

0

你可以用这个重写规则

RewriteBase/
RewriteRule ^(.+?/)\d+/$ $1 [R,L] 
+0

完美奥拉夫! 我刚刚写了一些非常相似的东西,看起来工作正常... 'RewriteCond%{REQUEST_URI}(。*)\/[0-9] {10,} \/$ RewriteRule。*%1 \/[R = 301,L]' – 2013-03-11 14:34:14

0

我写这这似乎工作确定剁数关。任何人都可以发现任何明显的错误?

RewriteCond %{REQUEST_URI} (.*)\/[0-9]{10,}\/$ 
RewriteRule .* %1\/ [R=301,L]` 
+0

你不需要跳过斜杠'/',你可能想要在字符串'RewriteCond%{REQUEST_URI} ^(。*)/ [0-9] {10}/$'。但除了我的挑剔之外,这看起来不错。 :-) – 2013-03-11 16:02:44