Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用htaccess重写Wordpress中的URL_Php_Wordpress_.htaccess_Url Rewriting_Permalinks - Fatal编程技术网

Php 使用htaccess重写Wordpress中的URL

Php 使用htaccess重写Wordpress中的URL,php,wordpress,.htaccess,url-rewriting,permalinks,Php,Wordpress,.htaccess,Url Rewriting,Permalinks,嗨,我需要在Wordpress中重写URL。 我有一个网站,页面是通过JSON文件加载的数据创建的。 这些数据允许我创建通过URL发送参数的自定义链接 我将永久链接设置为/%postname%/ 例如: 我需要改变一下 要做到这一点,规则是 RewriteEngine On RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /postname/?lid=$1&name=$2&st=$3 [L] 添加到htaccess中,但没有任何更改

嗨,我需要在Wordpress中重写URL。 我有一个网站,页面是通过JSON文件加载的数据创建的。 这些数据允许我创建通过URL发送参数的自定义链接

我将永久链接设置为/%postname%/

例如:

我需要改变一下

要做到这一点,规则是

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /postname/?lid=$1&name=$2&st=$3 [L]
添加到htaccess中,但没有任何更改

我使用一个插件“Wordpress的管理工具”,允许我更改htaccess

支持人士说: 我认为你走的路不对。听起来你好像在试图改变信仰

在页面的HTML输出中


Apache Rewrite无法做到这一点。在你问之前,不,管理工具没有任何帮助,也不可能有这样的功能,因为WordPress页面的生成方式(没有像Joomla中那样的文档缓冲区)


有人能告诉我是否有办法做到这一点吗?

“Apache Rewrite无法做到这一点。”-我认为“问题”是WordPress,而不是Apache。同时,您可以在
.htaccess
中使用mod_rewrite重写URL。在路由请求时,WP会在内部查看请求的URI,在使用Apache重写URL时,这一点不会改变。您需要在WP本身中以特定于WP的方式来完成这项工作。Apache的mod_rewrite处理这项工作的一个方向——将“pretty”URL的传入请求重写为带有参数的变量。它首先不处理那些漂亮URL的创建-如果您希望页面上的任何链接指向
/16036/John/2019-2020.html
,那么您需要确保系统首先创建相应的html代码。这就是支持人员想告诉你的。