I have to pass slug as well as other parameters to retrieve information but i want to hide parameters showing in url except slug. I have tried a lot with .htaccess but its still not giving me positive results.
Actual url is something like this http://localhost/qa1/reply.php?user_id=69%20&ans_id=44%20&id=71%20&post_url=what-is-the-best-example-of-agile-process
I want to convert this into http://localhost/qa1/reply/69/44/71/what-is-the-best-example-of-agile-process
This is the code from where i pass the parameters to reply.php page.
echo "<a href='reply.php?user_id=$user_id &ans_id=$ans_id &id=$id &post_url=$post_url'>view replies</a>";
And what I did in .htaccess below:
RewriteEngine On
RewriteRule ^reply/([0-9]+)/([0-9]+)/([0-9]+)/([0-9a-zA-Z]+) reply.php?user_id=$2&ans_id=$3&id=$4&post_url=$5
Nothing is showing except a blank white screen.
How do I solve the problem?
I thought it might make sense to summarize a bit in an answer. Especially after you comment asking about the redirection. You need to separate rewriting and redirection, since they need to oeprate in oposite directions:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^user_id=(\d+)&ans_id=(\d+)&id=(\d+)&post_url=([0-9a-zA-Z]+)$
RewriteRule ^reply\.php$ reply/%1/%2/%3/%4 [R=301,QSD]
RewriteRule ^reply/(\d+)/(\d+)/(\d+)/([0-9a-zA-Z]+)/?$ reply.php?user_id=$2&ans_id=$3&id=$4&post_url=$5 [END]
It is a good idea to start out with a http-302 redirection and only change that to a http-301 once everything works fine. That way you prevent caching issues while still developing...