I'm tying to set up the scenario, if someone visits website.com/blog/ they are redirected to blog.website.com.
I used this code in my .htaccess file to achieve some other redirection (from .net to .com) previously:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.|blog.)?website.net(.*) [NC]
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
It may also be relevant that I have an ErrorDocument 404 in my apache configuration file.
To solve my my problem I tried this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.|blog.)?website.net(.*) [NC]
RewriteRule (.*) http://www.website.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www.)?website(.com|.net)/blog/?$ [NC]
RewriteRule (.*) http://blog.website.com/ [L]
This code however is not working. My error document is still handling the request (the /blog/ directory doesn't exist). I tried moving this new code above the ErrorDocument in the apache conf file, but the same thing occurred.
It's no doubt a syntactical error, any help would be greatly appreciated :)
Under Modify a Subdomain, locate the domain you want to redirect, then click its Manage Redirection link on the right. In the text box, type the URL you would like visitors to be redirected to if they go to the subdomain sample1.hgexample.com. Click Save. You will see the redirected URL under the Redirection column.
in the .htaccess file in the root of your website.com directory
RewriteEngine on
RewriteBase /
RedirectMatch 301 ^/blog/(.*)$ http://blog.website.com/$1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With