Reputation: 745
.htaccess
RewriteRule ^classroom$ dashboard.php?section=classroom [NC]
url
http://localhost/elearning/classroom?keyword=all
php
echo $_GET['keyword'];
and the problem is why i cant get the value from the url?
can you guys help me to solve this one? Thanks .
Upvotes: 0
Views: 109
Reputation: 2701
When rewriting this URL, the original URL's query string will not be sent to the new URL. Place your .htaccess inside the elearning directory.
Change
RewriteRule ^classroom$ dashboard.php?section=classroom [NC]
to
RewriteRule ^classroom/(\w+)/$ dashboard.php?section=classroom&keyword=$1
Access URL:
http://localhost/elearning/classroom/all/
[UPDATE]
The above idea would work, but there's a standard way of achieving this by adding the QSA (Query String Append) flag for your original rewrite rule.
RewriteRule ^classroom$ dashboard.php?section=classroom [NC,QSA]
that will satisfy your request URL
http://localhost/elearning/classroom?keyword=all
Upvotes: 2