最新消息: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)

pages - How to show the root webpage on all subpaths

matteradmin9PV0评论

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: , 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.

Post a comment

comment list (0)

  1. No comments so far