0

Im trying add a rewrite rule for an old website that just undergone some renovation.

so far the rewrite rule is like /%year%/%monthnum%/%day%/%post_id%.html and now just need to change that to /%postname%.html

The issue is, since this is a non-English Unicode web portal, a typical old %postname%.html be like /%E0%A4%95%E0%A5%8D%E0%A4%AF%E0%A5%8B%E0%A4%82%20%E0%A4%95%E0%A5%81%E0%...html

So don't like that non-english string in url for old contents. And for new contents, we manually set English post slug from now on.

Is there any workaround like matching url and apply rules based on that like below?

if (preg_match("/^[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/(.+\.html)/",$uri)) {
    
           // appaly rewrite rule  `/%year%/%monthnum%/%day%/%post_id%.html`
        
    }elseif (preg_match("/^([^/]+).html)/",$uri)){
        
          // apply rewrite rule /%postname%.html
    }

And I also need to manipulate the permalink accordingly for contents published before and after(a date)

Any help please..

TELA
  • 41
  • 1
  • 7
  • The important thing is not, write a rule. This is pretty easy because you don't need to apply a condition. If you add a rule that works for both scenarios, there is no problem. But the problem is which scenario WordPress will choose when linking, which you cannot include both. In short, while all links in the form of "`postname.html`" are active, you add an extra access rule to the "`/../../posid.html`" page. – BOZ Jun 15 '21 at 07:01
  • So instead of planning to write multiple rules, clean up your special characters in SLUG and consider a single scenario. This will be much better. – BOZ Jun 15 '21 at 07:04

0 Answers0