1

I want to show the same page on all the subpaths on my web site

/events/
/events/firstOne
/events/secondOne/edit
/events/whatever/blahblahbla/helloworld

All that urls must load the same root page.

On that page (/events/) I have a react script that will handle everything from there with react router, but, right now, if I try to load any thing different than /events/, I just get a not found error.

How can I match a wildcard on that url?

EDIT:

I have tried to do it with add rewrite rule, as recomended on this answer: https://wordpress.stackexchange.com/a/213322/164509, but doesn't work either

I have added this to my funtions.php file:

// /public_html/wp-content/themes/kava/functions.php
<?php


function custom_rewrite_basic() {
  add_rewrite_rule('^events/([a-z]+)/', 'show_event', 'top');
}
add_action('init', 'custom_rewrite_basic');



if ( ! class_exists( 'Kava_Theme_Setup' ) ) {

    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * @since 1.0.0
     */ 
    class Kava_Theme_Setup {

        ....

Then I refresh the rewrite rules database by clicking on save permalinks on the admin page.

But when I try to load /events/asdf I still get a 404 not found error.

2
  • And what exactly is that "/events/" page? Is it a page? Is it a custom post type archive? Is it a taxonomy? And how does the React app know, where should it work? Is the 'events' part hardcoded? Commented Apr 5, 2019 at 10:34
  • It is a page wich only contains the header, footer and the <script> tag
    – Enuff
    Commented Apr 5, 2019 at 10:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.