regex - Redirect 301 of old urls to wordpress urls

admin2025-06-04  1

I am migrating a website from vivvo cms to wordpress. Vivvo is using category pages like index.numberofthepage.html

I want to redirect urls like using regex:

.200.html

to

/

mycats could be more than one category ex cat1/cat2... and the 200 could be any number. I used :

^/index.(.*?)\.html to ^/page/$1/

But not redirecting. Thanks

I am migrating a website from vivvo cms to wordpress. Vivvo is using category pages like index.numberofthepage.html

I want to redirect urls like using regex:

https://www.example/mycats/index.200.html

to

https://www.example/mycats/page/200/

mycats could be more than one category ex cat1/cat2... and the 200 could be any number. I used :

^/index.(.*?)\.html to ^/page/$1/

But not redirecting. Thanks

Share Improve this question edited Jan 6, 2019 at 18:54 yazuk asked Jan 6, 2019 at 14:58 yazukyazuk 851 silver badge5 bronze badges 4
  • Please add the context in which you are using the redirect rule. – fuxia Commented Jan 6, 2019 at 18:41
  • I migrated a website from vivvo cms to wordpress. Iwould like to avoid 404 errors. Vivvo is using category pages like index.**numberpage**.html – yazuk Commented Jan 6, 2019 at 18:51
  • I mean: are you using the regex in a PHP file, in an nginx config or in a .htaccess? Right now it's impossible even to guess what is wrong. – fuxia Commented Jan 6, 2019 at 19:18
  • using the regex in the plugin "Redirection" link – yazuk Commented Jan 6, 2019 at 22:53
Add a comment  | 

1 Answer 1

Reset to default 1

Since category and page number is dynamic, you can use htaccess and use this sample rewrite rule below:

RewriteRule (.*?)/index.(.*?)\.html $1/page/$2/

You can test the regex here - https://htaccess.madewithlove.be/ and I can see that it is working as far as I have tested it.

PS: URL Redirections are cached aggresively, you need to clear you browser cache completely to make sure that you are testing it properly.

Hope this helps!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749037640a315826.html

最新回复(0)