skip to Main Content

So I am having issue I want all requests from

https://transfinmedia.com/author?url=akchopra1-A268

to be 301 redirected on

https://transfinmedia.com/author/akchopra1-A268

but when i use

RewriteEngine on
RewriteCond %{QUERY_STRING} url=(.*) 
RewriteRule ^author(.*) /author/%1 [L,R=301,NC]

requests to

https://transfinmedia.com/author?url=akchopra1-A268 gets redirected on

https://transfinmedia.com/author/akchopra1-A268?url=akchopra1-A268

what am i doing wrong here, completely out of clue.

2

Answers


  1. change RewriteRule to

    RewriteRule ^author?url=(.*)$ /author/%1 [L,R=301,NC]
    

    Demo

    Login or Signup to reply.
  2. By default ,mod-rewrite appends old QueryString to the new target url. To discard QueryString ,you need to put a ? (an empty question mark) at the end of the target url.

    RewriteEngine on
    RewriteCond %{QUERY_STRING} url=(.*) 
    RewriteRule ^author(.*) /author/%1? [L,R=301,NC]
    

    Make sure to clear your browser cache before using this.

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