Wednesday, December 28, 2022
HomeWordPress Developmenturl rewriting - Rewrite rule to simulate web page hierarchy ends in...

url rewriting – Rewrite rule to simulate web page hierarchy ends in 404


On my WordPress website, I would like pages with slugs starting with outline- or result- to be accessible by requesting URI’s that start with define/ or outcome/ as an alternative, as if the pages in query have been subpages of a (nonexistent) define or outcome mum or dad web page.

For instance, when a customer sorts in https://instance.com/outcome/40-A, they’d be proven the web page with the slug result-40-A, with out the customer’s URL bar reflecting any change.

Nevertheless, that is giving me a 404 web page each time I take a look at it.

Right here is the code I’ve added to my theme’s features.php file:

/**
 * Rewrites sure web page URL's
 */
add_action('init', operate() outcome)/([^/].*)$',
        'index.php?pagename=$matches[1]-$matches[2]',
        'prime'
    );
);

So far as I am conscious, the common expression and substitute string are each appropriate. I’ve been flushing the rewrite guidelines cache after each experimental change to my code. I’ve additionally added the Question Monitor plugin and located that the rule is matching, however it’s being ignored—probably as a result of the resultant SQL question is not fetching the right web page?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments