Search code examples
.htaccesshttp-redirectslug

htaccess 301 Redirect issue


I have the following URL structures for my website:

http://domain.com/slug/1/test-test.html
http://domain.com/slug/2/test-test.html

and i want to change it to

http://domain.com/new-1-test-test.html
http://domain.com/new-2-test-test.html

i have already tried

RewriteRule ^slug$ /new- [R=301,L]
RewriteRule ^/?my\slug /new [R=301,L]

but it does't work.. anyone know how to redirect this with htaccess?

Thanks


Solution

  • RewriteEngine On
    RewriteRule ^slug/([0-9])/(.*)$ /new-$1-$2 [R-301,L]