Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.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 wordpress permalink系统是如何工作的?_Php_Wordpress_.htaccess_Mod Rewrite_Permalinks - Fatal编程技术网

Php wordpress permalink系统是如何工作的?

Php wordpress permalink系统是如何工作的?,php,wordpress,.htaccess,mod-rewrite,permalinks,Php,Wordpress,.htaccess,Mod Rewrite,Permalinks,Wordpress在.htaccess中使用此代码: 接下来,我不知道index.php如何处理这个问题。所以所有的URL都被重定向到index.php 如果我键入此URL: website.pl/One-two-Five .htaccess会将我重定向到index.php: 但是没有信息,我是说查询字符串之类的。这并不是说: website.pl/index.php?data=One-two-Five 但它只是: website.pl/index.php 这就是index.php。。。那

Wordpress在.htaccess中使用此代码:

接下来,我不知道index.php如何处理这个问题。所以所有的URL都被重定向到index.php

如果我键入此URL:

website.pl/One-two-Five
.htaccess会将我重定向到index.php:

但是没有信息,我是说查询字符串之类的。这并不是说:

website.pl/index.php?data=One-two-Five
但它只是:

website.pl/index.php

这就是index.php。。。那么index.php是如何做到这一点的呢?WordPress如何处理这个问题?我找不到任何答案。WordPress的机制是什么

好问题,也是我最近在中讨论的一个问题

正如您所说,所有不作为文件或目录存在的内容都将通过以下方式重写为index.php:

关于代码行:

RewriteRule ^index\.php$ - [L]
如果URL已经是index.php,那么这将阻止更多的处理。只说不要改变任何东西,[L]说停止处理这个迭代。这是因为.htaccess重写规则将重新启动处理,直到URL没有更改为止,因此它所做的是防止在第二次运行时进行文件系统检查

此后,WordPress检查$\u SERVER['REQUEST\u URI']变量以查看最初请求的页面,并对其进行操作。这就是为什么它不需要直接在.htaccess文件中传递任何内容到index.php的原因,因为最初请求的URL已经在$\u SERVER['REQUEST\u URI']变量中可用

另一点是,这些不是重定向,而是重写。重定向是外部的,返回到浏览器。重写仅在内部进行,不会更改浏览器的URL

website.pl/index.php?data=One-two-Five
website.pl/index.php
RewriteRule . /index.php [L]
RewriteRule ^index\.php$ - [L]