Change url query string using htaccess in wordpress

I want to change the url structure of a page in wordpress

from http://example.com/page-name/?id=rd123

in http://example.com/page-name/rd123/

I tried under code in .htaccess, I get ID if I use id numeric (123), but I get 404 page not found error if id alphanumeric (rd123) is used.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^page-name/([a-zA-Z0-9-]+)/?$ pagename.php?id=$1 [L]
</IfModule>

      

what I am missing in the code above is in Wordpress and I am not getting any perfect solution. here, the page name is the template.

+3


source to share


2 answers


Try it,



# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^page-name/(.*)/?$ page-name/index.php?id=$1 [L,QSA,NC]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>
# END WordPress
      

Run code


0


source


In this case, use:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page-name/([a-zA-Z0-9-]+)/?$ page-name/index.php?id=$1 [L]
</IfModule>

      



It's not a problem with alphanumeric ...

+1


source







All Articles