Php 如何在wordpress for pretty URL中使用.htaccess更改GET变量

Php 如何在wordpress for pretty URL中使用.htaccess更改GET变量,php,wordpress,apache,.htaccess,mod-rewrite,Php,Wordpress,Apache,.htaccess,Mod Rewrite,我知道如何在PHP中更改URL,但我不是WordPress方面的专家 我有这个网址: domain.com/parent page/child page here/?id=SomeText 我想要这个 domain.com/parent-page/child-page-here/Some Text: 我更改了.htaccess,但它在这里不起作用是我的.htaccess代码 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngin

我知道如何在
PHP
中更改URL,但我不是WordPress方面的专家

我有这个网址:

domain.com/parent page/child page here/?id=SomeText

我想要这个

domain.com/parent-page/child-page-here/Some Text:

我更改了
.htaccess
,但它在这里不起作用是我的
.htaccess
代码

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteRule ^parent-page/child-page/([0-9a-zA-Z]+) parent-page/child-page/?id=$1 [NC,L]
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
重新启动发动机
重写规则^parent page/child page/([0-9a-zA-Z]+)parent page/child page/?id=$1[NC,L]

无需使用.htaccess,因为Wordpress附带了您所需的功能。您所要做的就是从管理仪表板更改永久链接as

@mapmalith是正确的,使用WordPress,您只需更改设置中的永久链接即可

但是,如果出于任何原因无法执行此操作,则可以在
.htaccess
文件中使用以下命令:

RewriteEngine On
RewriteRule ^parent-page/child-page-here/([^/]*)$ /parent-page/child-page-here/?id=$1 [L]
它将为您留下以下URL:
domain.com/parent page/child page here/SomeText
。在测试之前,请确保清除缓存


显然,您需要将目录重命名为正确的名称。

我使用的是来自parmalink的post name。我正在以id=“text”的形式发送数据,并从自定义页面$_GET[“id”]获取数据,并将此值发送到数据库以获取结果。请告诉我如何从.htaccess文件更改URL,然后立即执行此操作:^parent page/child page/([a-zA-Z0-9-])/?$parent page/child page/index.php/?id=$1[L]但它不起作用我已经选择了post name表单dashboard,我刚刚试过你编码它不起作用它给我内部服务器错误这是我的.htaccess文件(#开始WordPress RewriteEngine On RewriteRule^ aircraft gallery/aircraft gallery class/([^/]*)aircraft gallery/aircraft gallery class/?id=$1[L]RewriteBase/RewriteRule^index\.php$-[L]RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule./index.php[L]#END WordPress)你在吗。。?