Search code examples
apache.htaccesshttp-status-code-301

Website article .htaccess 301 redirect


I have a site in a folder called patients and my urls look like so:

http://site.com/patients/post-name

http://site.com/patients/articles/another-post-name

I want to redirect them all to a clean:

http://newsite.com/post-name

http://newsite.com/another-post-name

In other words, lose the /articles/ which sometimes appears and 301 to the new site.

Any help on how to do this with htaccess?


Solution

  • Edit your .htaccess in http://site.com server and put this(must be the first rule):

    RewriteEngine On
    
    RewriteRule .* http://newsite.com/ [R=301]
    

    or

    Redirect 301 / http://newsite.com/
    

    Regards.