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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

Are 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