开发者

regex for htaccess redirect

Looking for a regex to redirect (remap) old URL to the Wordpress site efficiently.

The goal is to redirect all the old URL to a new set of URLs without losing the pagerank ( 301 redirect )

/file/Abc_123_ABC_Abc.shtml to be /abc-123-abc-abc

Objectives:

1.remove /file/

2.convert to lowercase

3.replace all _ with - (appears about 2 to 4 times in a URL)

4.remove the extension (both .htm & .shtml)

How to achive the 开发者_开发技巧point 3 in htaccess redirect?


Almost identical use-case (the only difference is the lowercase and the folder name):

HTACCESS : RegEx match replace for URL

Best I'm aware, you cannot lowercase using a rewrite rule, so you'll need to rewrite to a redirect handler, and process it from there:

RewriteBase /
RewriteRule ^file/(*+)\.html?$ /file/redirect.php [L,QSA]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜