简体   繁体   中英

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM