2011-09-23 89 views
-1

我想重定向URLhtaccess的正則表達式語法

http://www.domain.com/category/abc-xyz-zzz-2010-150857.html 
to 
http://www.domain.com/category/150857-abc-xyz-zzz-2010.html 

但如果

http://www.domain.com/category/150857-abc-xyz-zzz-2010.html 
not redirect 

這是我的htaccess,但不起作用

RewriteRule ^([^.]+)/([A-Za-z]+)-([0-9]+).html$ $1/$3-$2.html [L,R=301] 

普萊斯幫我解決它

我修正了

RewriteRule ^([^.]+)/([A-Za-z]*)-([^.]+)-([0-9]+).html$ $1/$4-$2-$3.html [L,R=301] 

回答

0

試試這個: RewriteRule ^([^.]+)/([0-9]+)-([A-Za-z0-9]+).html$ $1/$3-$2.html [L,R=301]

0
RewriteRule ^category/([a-zA-Z]*)-([a-zA-Z]*)-([a-zA-Z]*)-(\d+)-(\d+).html$ category/$5-$1-$2-$3-$4.html [L] 
0
^([^.]+)/([A-Za-z]+)-([0-9]+).html$ $1/$3-$2.html 

你這裏的問題是,你不走短線,甚至第二組數字的考慮。這一個應該工作:

^(.+)/([A-Za-z\-]+)-([0-9]+)-([0-9]+)\.html$ $1/$4-$2-$3.html