Surya Teja
Surya Teja

Reputation: 9

How to pass an extra parameters in SEO friendly urls?

I have a SEO friendly url like this : /blog/post/15

But now i want to pass an extra parameter like this:

/blog/post/15/?show_comments=1

But when i'm trying to access value of parameter 'show_comments' its returning null value.

I'm using follwing rewrite rule in .htaccess

RewriteRule ^blog/post/([^/\.]+) blog/post.php?id=$1&show_comments=$2 [L]

Note:- I don't want to pass extra parameter in url like this /blog/post/15/1

Upvotes: 0

Views: 486

Answers (1)

C3roe
C3roe

Reputation: 96240

The original query string got replaced with the one you created in your substitution URL.

You need to use the QSA flag (Query String Append) here to merge your new parameters with the already existing ones:

RewriteRule ^blog/post/([^/\.]+) blog/post.php?id=$1&show_comments=$2 [L,QSA]

Upvotes: 3

Related Questions