Rewrite URL in PHP with mod_rewrite


The web server is Apache. I want to rewrite URL so a user won't know the actual directory. For example: The original URL:

Expected URL:

How to achieve it with mod_rewrite?

You need to define a rewrite rule (should be similar to this):

RewriteRule ^/(.*)/en/piecework/(.*)piecework_id=([0-9]+)(.*)$3

and put it in a .htaccess file under the main folder of you site

Full description of Rewrite rules here:


Made a mistake in my rule, hopefully I corrected it.