Redirect site.com/guide/* to newsite.com/guide/* with .htacc

Hey Guys,

I know that this shouldn't be too hard to do, but the problem is that I have a WordPress in a folder, not the root domain. I have my .htaccess file all set up in the root folder, but not for the WordPress folder.

I wanted to know how to redirect:

  • www to non-www

  • site.com/guide/ to newsite.com/guide/

  • and site.com/guide/some-article/ to newsite.com/guide/some-article/

I was playing around with things, but site.com/guide/some-article/ was redirecting me to newsite.com/some-article/, not newsite.com/guide/some-article/. I would post the code here, but I got rid of it and saved the changes.

The www to non-www seems to be working with this snippet:

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Thanks for the help!

1 Reply

RewriteEngine On RewriteCond %{HTTP_HOST} site\.com RewriteRule ^/(.*) http://newsite.com/$1 [R=301,QSA,L]

Untested, but it should work.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct