How to rewrite my URL from http://www.mysite.com/listingsecond.php?ID=1 to http://www.mysite.com/listingsecond?

How can I rewrite to my .htaccess in PHP to do this?

  • You can search on Google, I just found on Stack Overflow the answer to your question. – Zistoloen Feb 22 '14 at 9:50
  • what you want is to redirect without using .htaccess? If that is what you want, my answer may help, if that is not what you want, please clarify the question a bit. – PatomaS Feb 22 '14 at 9:52
  • Or are you wanting to --write to your .htaccess file using PHP?? – MrWhite Mar 13 '15 at 16:42

On your PHP file, use the $_GET variable to process the query as you need, then when generating the response, redirect to the address that you want using the header function. Specifically, the location attribute

Not the answer you're looking for? Browse other questions tagged or ask your own question.