This should work:
RewriteEngine on
RewriteRule ^sub1/(.*)/([0-9]+)-(.*)$ /sub1/testing.php?s=$2 [R=301,L]
Question
Usually is the other way aroud, but I need to redirect my static urls to dynamic ones as a variable part of the first one.
I need to redirect:
http:/example.com/sub1/sub-2/2014147-test-page-45x.html
http:/example.com/sub1/sub-6/8014149-test-24page.html
http:/example.com/sub1/sub-25/7514157-58test-page.html
to
http://example.com/sub1/testing.php?s=2014147
http://example.com/sub1/testing.php?s=8014149
http://example.com/sub1/testing.php?s=7514157
I know I need to use %{REQUEST_URI}, but I can't put it together.
Any help will be appreciated.
Thanks.
Solution 2
This should work:
RewriteEngine on
RewriteRule ^sub1/(.*)/([0-9]+)-(.*)$ /sub1/testing.php?s=$2 [R=301,L]
OTHER TIPS
Assuming your .htaccess is at root of example.com, adding following to it will do the trick.
RewriteEngine On
RewriteBase /
RewriteRule ^sub1/[^/]+/(\d+).*$ sub1/testing.php?s=$1 [R,L]