Domain redirect via .htaccess Java script nginx

I send from helo@green.net. I don’t want when someone goes to - green.net to see “this is a mail-in-a-box” so i want to redirect the domain green.net to green.com
if i add the rule below in .htaccess of green.net would it work fine? Would it influence the normal workflow of the mail server?

RewriteEngine on
RewriteRule ^(.*)$
http://www.green.com/$1 [R=301,L]

Thank you!

No way because Apache is not being used … Perhaps, adapting this trick may help you to achieve what you are asking for.

1 Like

Ok, The java redirect works fine but all it redirects is the root domain NET to COM, which in my case is not enough. So i did the following: I logged in MiaB with WinSCP and found root/etc/nginx/nginx.conf and added the following change:

http {

server {
	server_name .green.net;
	return 301 https://www.green.com$request_uri;
}

Which works fine and redirects not only the root domain (green.net > green.com), but also would redirect a link like green.net/one/two/three/four > green.com/one/two/three/four

but here comes the difficult part i want to keep all redirects described above and at the same time i want to be able to redirect a subdomain - one.green.net/monday/tue/wen-4 > one.green.info/monday/tue/wen-4

Here is the last i tried, which does NOT work. If s.o. knows what is wrong with that one below, that would definitely be the high line of the month.
http {

server {
	server_name .green.net;

	#if ($request_uri ~ monday) {
		#return 301 https://one.green.info$request_uri; 
	#} else {
		return 301 https://www.green.com$request_uri;
	#}
}

Just note that /etc/nginx/nginx.conf and /etc/nginx/conf.d/local.conf will get reset to default values after each MiaB upgrade. Good luck!

Yes ok. That is not an issue. What bothers me more is what exactly is wrong with the rules i write.

Here is how nginx.conf should be changed in order to be able to redirect to two different domains. Briefly that would redirect sub1.green.net/one/two/three/four > green.com/one/two/three/four
and
sub2.green.net/monday/tue/wen-4 > one.green.info/monday/tue/wen-4

http {

server {
	server_name sub1.green.net;

	return 301 http://www.green.com$request_uri;
}
server {
	server_name sub2.green.net;

	return 301 http://sub2.green.co.uk$request_uri;
}



##
# Basic Settings
##

cheers