John Davidson

.htaccess - Problem not reading GET in frindly url in PHP

0 comments
Message:


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 !!



My Answer:
It seems like there might be an issue with your .htaccess file configuration. Here is a revised version of your .htaccess file code that should work for your scenario:


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^post/([0-9]+)/?$ index.php?id=$1 [L]


This code will rewrite URLs like `post/122` to `index.php?id=122` and should correctly pass the GET parameter to your PHP script. Make sure to save the changes to your .htaccess file and test it again. Let me know if you encounter any further issues.

Rate this post

3 of 5 based on 9394 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us