[英]How to change GET variables using .htaccess in wordpress for pretty URL
I know how to change URL in PHP
but I am not an expert in WordPress. 我知道如何在
PHP
更改URL,但我不是WordPress专家。
I have this URL: 我有这个网址:
domain.com/parent-page/child-page-here/?id=SomeText
and I want this 我想要这个
domain.com/parent-page/child-page-here/Some Text: domain.com/parent-page/child-page-here/某些文本:
I changed .htaccess
but its not working here is my .htaccess
code 我更改了
.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]
@mapmalith is correct, with WordPress you can simply change the permalinks in your settings. @mapmalith是正确的,使用WordPress,您只需更改设置中的永久链接即可。
However, if for whatever reason you're unable to do this, then you can use the following inside your .htaccess
file: 但是,如果由于某种原因而无法执行此操作,则可以在
.htaccess
文件中使用以下命令:
RewriteEngine On
RewriteRule ^parent-page/child-page-here/([^/]*)$ /parent-page/child-page-here/?id=$1 [L]
It will leave you with the following URL: domain.com/parent-page/child-page-here/SomeText
. 它将为您提供以下URL:
domain.com/parent-page/child-page-here/SomeText
。 Just make sure you clear your cache before you test this. 只需确保在测试前清除缓存即可。
Obviously you will need to rename the directories to the correct names. 显然,您需要将目录重命名为正确的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.