0

I'd like to rewrite URL using wordpress. like /name/1/2/ to /name?last_name=1&first_name=2 I've tried few ways. i.e. following code. But it seems not working well. Is there any way to do that ?

Thank you

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^name/(\d+)/(\d+)/ index.php?p=9&last_name=$1&first_name=$2 [QSA]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
toshipon
  • 53
  • 1
  • 5

1 Answers1

0

try this

RewriteRule ^name/(\d+)/(\d+)/ index.php?p=9&last_name=$1&first_name=$2 [QSA, L]

You can refer to this post What is L in [QSA, L] in htaccess for understanding QSA and L flag.

QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite (olle?p=1 will be rewritten as index.php?url=olle&p=1.

L means if the rule matches, don't process any more RewriteRules below this one.

Community
  • 1
  • 1
Sylwit
  • 1,497
  • 1
  • 11
  • 20