Home > Back-end >  Problem not reading GET in frindly url in PHP
Problem not reading GET in frindly url in PHP

Time:02-12

If you look at the YouTube site when you search, you will see that there is a URL result and then method.

For example:

https://www.youtube.com/results?search_query=s

My .htaccess file code:

Options  FollowSymLinks
RewriteEngine on
 
RewriteRule  post/(.*)/ index.php?id=$1
RewriteRule post/(.*) index.php?id=$1

I want to put post/122 on that page for paging, for example, and I want method to be added here.

But this is where the new problem begins. Because the Get function is no longer read.

URLs are tests !!

CodePudding user response:

you will need the QSA flag for the rewrite rule then it will append the original query string into the new uri

Options  FollowSymLinks
RewriteEngine on
 
RewriteRule  post/(.*)/ index.php?id=$1 [QSA]
RewriteRule post/(.*) index.php?id=$1 [QSA]

see https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#RewriteRule

  • Related