WordPress页面php片段以获取所有请求到子目录
我正在为WordPress网站页面开发PHP片段。想象一下,此片段位于位于一个页面上,
wp-example.com/abc
但是当我致电
wp-example.com/abc/def
WordPress时,假设它是完全不同的页面,并且说页面不存在,并且我的片段不应用。
在我的php片段中,位于wp-example.com/abc
上,如何将所有请求获取到SubDirectories example> example> example.com/abc/**
?
编辑:我不想修改我的Web服务器配置,我想纯粹在WordPress中执行此操作
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过添加到
.htaccess
文件2行来解决此问题:(未测试)You can solve this by addding to
.htaccess
file 2 lines: (not tested)使用此.htaccess代码。
Use this .htaccess code.
步骤1:允许多站点
启用网络设置菜单项,您必须首先在 wp-config.php 文件中定义多站点。
打开wp-config.php并在上面添加此行 ,它说这就是停止编辑! Happy Bloging .. 如果在任何地方都没有说,请添加以要求开头的第一行以上的某个地方或包括:
步骤2:安装网络
上一步启用启用网络设置您的工具菜单中的项目。使用该菜单项,转到创建WordPress站点网络屏幕。
要查看创建WordPress网站网络屏幕网络的示例,请查看管理> tools>网络设置。在所有情况下,屏幕看起来都不完全相同。显示的示例是用于Localhost上的安装,该安装限制了可用的选项。
https://prnt.sc/28zphhke7zuq
您的网络,按照创建WordPress站点屏幕网络上的说明。您看到的说明是为安装定制的。它们可能与您在此处看到的示例不同。
https://prnt.sc/xbgn0dubwmjr 直接上方
该片段看起来像这样,但是适应您自己的网站:
将第二个代码段添加到 .htaccess 文件中并替换其他WordPress规则。
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.