Post4VPS Forum | Free VPS Provider

Full Version: Redirect link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I already change the site port 80 throw another port so i was wondering if this could be possible,
when people type the server site with default port  it will redirect him throw another link is that possible with Apache ?
OS: Debian 8 Jessie
Do you mean by,

User A opened blabla.com, and redirected to blahblah.net by Apache?

AFAIK, this is possible, but since I'm a newbie, I'll leave what I found on Google.

https://www.linode.com/docs/web-servers/...eb-server/
It can be done via the firewall without any changes to the web server.

Code:
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports <new port here>

Try the rule above. Don't forget to change the <new port here> part to the port that you want to redirect to.

An alternative:
Code:
iptables -t nat -I PREROUTING --src 0/0 --dst <your server ip> -p tcp --dport 80 -j REDIRECT --to-ports <new port here>

Here again make sure you adjust <new port here> and also <your server ip>.

If the server is OpenVZ and doesn't have the NAT iptables modules loaded on the hostnode the commands might fail. In that case you might have to build a vHost on port 80 that redirects to the other port. For that take a look at this: https://stackoverflow.com/a/13089668


My references for the iptable rules:
- https://www.cyberciti.biz/faq/linux-port...-iptables/
- https://wiki.debian.org/Firewalls-local-...edirection


P.S.: "throw"? You mean "to". Throw means absolutely something different.
Thanks for replying but i found a results by my own. after some research i finally got it, actually i'm using apache 2 so
i have edited /etc/apache2/apache2.conf there where i enabled .htaccess by changing AllowOverride None to AllowOverride All.
And use those commands to restart apache2
Code:
systemctl restart apache2
netstat -tlpn| grep apache
ss -tlpn| grep apache

and thats it for redirect i have used "Redirect / http://example.com" on my .htaccess".
(06-06-2019, 12:07 AM)Melvin Wrote: [ -> ]I already change the site port 80 throw another port so i was wondering if this could be possible,
when people type the server site with default port  it will redirect him throw another link is that possible with Apache ?
OS: Debian 8 Jessie

you can redirect it many ways using apache
using apache itself , using simple php script . just header(Location and die() , using javascript or using html meta tag redirect header
i mostly use the php location and nginx redirect because i only use apache for phpmyadmin
(06-06-2019, 10:27 AM)humanpuff69 Wrote: [ -> ]you can redirect it many ways using apache
using apache itself , using simple php script . just header(Location  and die() , using javascript or using html meta tag redirect header
i mostly use the php location and nginx redirect because i only use apache for phpmyadmin
apache for my public html already installed with my Game panel it just allow .htaccess from apchace2.conf SO i can redirect and edit my site.
Glad to see you found something that works. I totally forgot about using rewrite via htaccess. Hehe. I'm using the redirect option in Nginx. Apache isn't my thing so I must have totally forgotten about htaccess.