I have a plugin which creates sites progmatically. What I need to do is ad a /s/ inbetween the domain and the site name in the URL.





I have changed the sites url by adding /s/ to the path when calling wpmu_create_blog() .

I now need to update the rewrite rules to cater for the added s.

add_rewrite_rule('^/s/([0-9]+)/?', 'index.php?', 'top');

What do I add to the second part of the rewrite rule (after index.php?, so that the site will load correctly?)

  • I don't think you'd be adding it to index.php (as it's a WordPress core-file). .htaccess is where that kind of thing gets done. codex.wordpress.org/htaccess#Multisite – admcfajn Mar 7 '18 at 16:15
  • 1
    I am not adding it index.php, I am adding it to the index.php part of the rewrite rule. I have updated the question to be clearer. – frank astin Mar 7 '18 at 16:50
  • have you tried this? add_rewrite_rule('^/s/([0-9]+)/?', '/s/index.php?', 'top'); or this add_rewrite_rule('^/s/([0-9]+)/?', 's/index.php?', 'top'); ... .htaccess files can run in each directory, so there's that to consider too. – admcfajn Mar 7 '18 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.