admin管理员组文章数量:1122846
I want to create a SEO friendly URL in WordPress, i am developing a site in WordPress it has several custom pages with custom PHP Script. I am sending data in id="some text" and matching this text from my database when i GET['id'] the parameter. i already selected my setting from dashboard.
Post name /
I have Currently this URL domain/parent-page/child-page/?id="some text"
and Now i want this one domain/parent-page/child-page/some-text I have modify my .htaccess file here is my code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^parent-page/child-page/([a-zA-Z0-9]+)/$ parent-page/child-page/index.php/?id=$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
i don't know why its not working
I want to create a SEO friendly URL in WordPress, i am developing a site in WordPress it has several custom pages with custom PHP Script. I am sending data in id="some text" and matching this text from my database when i GET['id'] the parameter. i already selected my setting from dashboard.
Post name http://domain.com/sample-post/
I have Currently this URL domain.com/parent-page/child-page/?id="some text"
and Now i want this one domain.com/parent-page/child-page/some-text I have modify my .htaccess file here is my code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^parent-page/child-page/([a-zA-Z0-9]+)/$ parent-page/child-page/index.php/?id=$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
i don't know why its not working
Share Improve this question edited Jul 18, 2017 at 12:22 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jul 18, 2017 at 11:04 Shehzad AhmedShehzad Ahmed 113 bronze badges1 Answer
Reset to default 0Are you failing to supply the trailing slash on the pre-rewrite URL? That regex won't match without it.
Since your /parent-page and /parent-page/child-page are WordPress pages you shouldn't be using .htacceess for this at all, because it would prevent WordPress from loading for those URLs. Instead you should be hooking to query_vars
so WordPress won't strip your new variable from the querystring and to rewrite_rules_array
to handle the actual rewrite.
本文标签: phpHow to change query string with pretty URL in WordPress using htaccess file
版权声明:本文标题:php - How to change query string with pretty URL in WordPress using .htaccess file 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736291431a1928722.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论