$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>regex - Redirect 301 of old urls to wordpress urls|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

regex - Redirect 301 of old urls to wordpress urls

matteradmin9PV0评论

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!

Post a comment

comment list (0)

  1. No comments so far