简体   繁体   中英

.htaccess RedirectMatch regex issue

I'm trying a redirection with this code in my .htaccess file. What's wrong with it?

It runs seamlessly without regex (first line) but no way to execute the redirection with regex on the second line.

RedirectMatch 301 /videos/100067.mp4 http://test.com/video/100067/dfts4555444.mp4

RedirectMatch 301 /videos/^([0-9]+)?$.mp4 http://test.com/video/$1/([a-z0-9]+).mp4

^ and $ match the start and end of a string, respectively.

Something like this should work better:

RedirectMatch 301 ^/videos/([0-9]+)\.mp4$ http://test.com/video/$1/$1.mp4

I have no idea where you are getting the last part of the resulting url from, the dfts4555444.mp4 part. I used $1 to make it work for now.

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