简体   繁体   中英

URL manipulation with rewrite rules

I have URLs like these:

http://hi.com/id1-tag1-tag2-tag3.jpg
http://hi.com/id2-tag1.jpg
http://hi.com/id3-tag1=tag2-tag3-tag4-tag5.jpg

I need a rewrite rule so that it will drop all the tags and then format the URL so that it's

http://hi.com/id1.jpg
http://hi.com/id2.jpg
http://hi.com/id3.jpg

id will always be a unique identifer.

Thanks.

You can use this rule in your document root:

RewriteEngine On

RewriteRule ^([^-]+)-.+?\.jpg$ /$1.jpg [NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM