I need help modify a file .htaccess delete characters from URL and redirect. The file .htaccess is currently empty.

  1. I want to change the word article to the word topic in all the URLs.

The current URL:

  1. I want to delete the last characters of the URLs &lang=en and some URLs &lang=

The current URLs:


So the final URL:

  • 1
    Have you tried anything yet?
    – PatomaS
    Mar 3, 2014 at 7:03

1 Answer 1


With the following code:

  • Line 1: Just a block header comment to explain what happens in the code snippet
  • Line 2: Requires a parameter match of the action=article value pair;
  • Line 3: Captures the cat_id value into parameter %2.
  • Line 4: Captures the id value into parameter %5.
  • Line 5: Could be used to capture the lang value (commented out / not in use).
  • Line 6: Rewrites internally to a hard-coded URL with parameters specified.

If you wished to use the lang value at some point in the future you would simply need to append &lang=%8 to the end of line 6 and remove the # comment prefix from line 5.

# Change action parameter value from article to topic and drop lang parameter
RewriteCond %{QUERY_STRING} action=article
RewriteCond %{QUERY_STRING} ^(.*&)?cat_id=([^&]+)&?(.*)?$
RewriteCond %{QUERY_STRING} ^(.*&)?id=([^&]+)&?(.*)?$
#RewriteCond %{QUERY_STRING} ^(.*&)?lang=([^&]+)&?(.*)?$
RewriteRule ^index\.php(.*)$ index.php?action=topic&cat_id=%2&id=%5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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