By Nay
How I to do a redirect in .htaccess in this way?
www.domain.com/blog/* --> www.domain2.com/* www.domain.com/blog/ir/* --> www.domain2.com/ir/*
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Add the following to domain.com’s .htaccess:
RedirectMatch 301 ^/blog/(.*)$ http://www.domain2.com/$1
Take a look at the following tutorial:
Heya,
To achieve the redirects you want using .htaccess, you’ll need to use mod_rewrite rules. Here’s how you can set up the redirects:
Redirect www.domain.com/blog/* to www.domain2.com/*:
This rule will redirect any request that starts with /blog/ to the corresponding path on www.domain2.com.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^blog/(.*)$ https://www.domain2.com/$1 [L,R=301]
www.domain.com/blog/ir/* to www.domain2.com/ir/*:This rule is specific to URLs that start with /blog/ir/ and will redirect them to the corresponding path on www.domain2.com/ir/.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^blog/ir/(.*)$ https://www.domain2.com/ir/$1 [L,R=301]
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.