I move part of my site to subdomain and want that link of that component redirect to subdomain. I want if user come to site with moved component link he will redirect to subdomain.

https://domain.com/cat/item -> https://sub.domain.com/cat/item

Need some code in htaccess. Please help with

1 Answer 1


You can find many answers searching around. My favorite reference:

.htaccess Snippets https://github.com/phanan/htaccess

You can start with:

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

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.