How to Add Domain Redirection in Vesta CP
| |Well I think this topic is pretty interesting: how to create domain / web redirection using VestaCP. The solution is basically simple which I think if you are familiar enough with LAMP (or say Apache), but it is pretty confusing for some newbies. So here it is a short / quick Vesta Control Panel tutorial dedicated for newbie.
Unlike WHM/cPanel that provides certain menu to create Domain Redirection so a user will understand what is it and how to use it, VestaCP doesn’t have that feature so users will have to make use of and create Apache .htaccess Redirection manually.
This is in WHM/cPanel
And do this in VestaCP
Step 1 – Install VestaCP on your server. Follow step 1 till 4 (Stage 1) of this tutorial to get it done.
Step 2 – Now login to VestaCP dashboard and add new website. Click on WEB menu then click Add Web Domain.
Step 3 – Type in the domain name you want to forward / redirect then click the green Add button.
once done you’ll see this message:
In this example I will redirect servermomtest.com to servermomtest.org
Step 4 – Now launch Putty or Terminal up and login to your server via SSH as root or as user with sudo privilege (or as admin if you configured admin to have SSH access)
Step 5 – Now go to web directory of your newly added website/domain which it should be at this location:
cd /home/user/web/domain.tld/public_html
In my situation it is:
cd /home/admin/web/servermomtest.com/public_html
replace user and domain.tld with your own. Example:
Step 6 – Create new .htaccess file (or edit it if it’s created already):
nano .htaccess
Step 7 – Now put these lines in there:
RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule ^(.*)$ http://example.org/$1 [L,R=301,NC]
the htaccess redirection above does 301 redirect from example and www.example.com to http://example.org and so that old links to example.com carry over. Just replace example.com and example.net above with your own.
Now save changes and exit the editor. In Nano it is Control+O then Control+X.
That’s it. Now everytime anyone opens example.com or www.example.com will be forwarded to example.com. And so if anyone opens example.com/any-link or www.example.com/any-link will be redirected to example.org/any-link. Cool huh?
I really hope that helps.
Very helpful topic but i have an question.
That is, if my domain is example.com and i am just using this server for redirect it to same domain like example.com and all the content is on another server so i want it to redirect to another server with different ip address where this domain is actually hosted so in this case what i need to do.
Please reply soon
Best Regards
Shahroz
Sorry but I don’t quite understand about “redirect example.com to same domain like example.com”, why and what for you redirect same domain (I just don’t get it). But, if what you really mean is: to use a server as frontend proxy for your domain but the real files of your website are stored in another server, then you don’t have to install VestaCP. Simply install Nginx or Varnish will help.
Yeah)
This help me)
Thanx
hello mom
after redirect my domain to another site,what can i do to return it into normal form without redirection.i use vestacp
thankyou
As per above tutorial, you can simply delete the .htaccess file and that’s it.
my domain dsc.co.ir redirect to didebansystem.ir but i cannot direct it.i edit htaccess its not true.
i delete both domain but yet dsc redirect to didebansystem.i am really confused.anyone can help me.in fact i miss my domain.
My .htaccess is not working, i think its because i have to change AllowOverride None – to – AllowOverride All in my DigitalOcean Ubuntu.
The question is, how i can do this? Please somebody help? Tks.