skip to Main Content

I am trying to do 301 redirect from the below URL

www.example.com/categories/Writing-Translation

to

www.example.com/categories/Writing-Translation-jobs

However, it is always redirecting a page with the following url

www.example.com/categories/categories/Writing-Translation-jobs?cid=Writing-Translation

This is the htaccess code used for redirection

301 Redirect

RewriteCond %{QUERY_STRING} ^cid=Writing-Translation$ [NC]    
RewriteRule ^categories/Writing-Translation$ https://www.example.com/categories/Writing-Translation-jobs [R=301,NE,NC,L]

2

Answers


  1. Chosen as BEST ANSWER

    It worked with the following rule by adding "/?" in the beginning:

    RewriteRule ^/?categories/Writing-Translation$ https://www.example.com/categories/Writing-Translation-jobs [L,R=301]


  2. You may use this rule as your topmost rule:

    RewriteCond %{QUERY_STRING} ^cid=Writing-Translation$ [NC]    
    RewriteRule ^categories/Writing-Translation$ /categories/Writing-Translation-jobs? [R=301,NC,L]
    

    ? at the end of target URI will strip off existing query string. Make sure to test it in a new browser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search