I am developing a PHP snippet for a WordPress website page. Imagine this snippet is at a page located at
wp-example.com/abc
But when I call
wp-example.com/abc/def
WordPress assumes it is a totally different page and says page does not exist, and my snippet is not applied.
In my PHP snippet, located at wp-example.com/abc
, how can I fetch all the requests to subdirectories example.com/abc/**
?
edit: I don’t want to amend my web server configuration, I want to do that purely within WordPress
3
Answers
You can solve this by addding to
.htaccess
file 2 lines: (not tested)Use this .htaccess code.
Step 1: Allow Multisite
To enable the Network Setup menu item, you must first define multisite in the wp-config.php file.
Open up wp-config.php and add this line above where it says That’s all, stop editing! Happy blogging.. If it doesn’t say that anywhere, then add the line somewhere above the first line that begins with require or include:
Step 2: Installing a Network
The previous step enables the Network Setup item in your Tools menu. Use that menu item to go to the Create a Network of WordPress Sites screen.
To see an example of the Create a Network of WordPress Sites screen, look at Administration >Tools > Network Setup. The screen does not look exactly the same in all circumstances. The example shown is for an installation on localhost, which restricts the options available.
https://prnt.sc/28ZPHhke7ZuQ
Step 3: Enabling the Network
To enable your network, follow the instructions on the Create a Network of WordPress Sites screen. The instructions that you see are customized for your installation. They might not be the same as the examples you see here.
https://prnt.sc/XBGn0dUbWMJR
Add the first code snippet to your wp-config.php directly above the line
The snippet looks like this, but adapted to your own site:
Add the second code snippet to the .htaccess file and replace other WordPress rules.