简体   繁体   中英

Need help forming mod_rewrite rule

Ok on my site I want it to be so when people visit http://mysite.com/201209041 it will redirect to http://mysite.com/[first 4 digits]/[next two digits]/[next two digits]/[all other digits]/index.html so in my example it would redirect to http://mysite.com/2012/09/04/1/index.html and in another example http://mysite.com/20120904259872 would redirect to http://mysite.com/2012/09/04/259871/index.html

How do I go about doing this?

of course you could split the url like so:

RewriteRule ^(\d{4})(\d{2})(\d{2})(\d*)$ /$1/$2/$3/$4/index.html [L,R]

In my opinion a PHP approach would be the better alternative though.

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