Problems activating your account? Send notification email to: admin@post4vps.com
Host4Fun Budget VPS Hosting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redirect link
#1
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
Thanks to Post4VPS and Host4Fun for my amazing VPS 1 
#2
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/
Thanks to HostDoc and Post4VPS for providing me excellent VPS 13!
Give me questions I can't answer not answers I can't question. - Richard Feynman
#3
It can be done via the firewall without any changes to the web server.

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:
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.
Kind regards
Hidden Refuge
#4
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
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".
Thanks to Post4VPS and Host4Fun for my amazing VPS 1 
#5
(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
Terminal
humanpuff69@FPAX:~$ Thanks To Shadow Hosting And Post4VPS for VPS 5
#6
(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.
Thanks to Post4VPS and Host4Fun for my amazing VPS 1 
#7
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.
Kind regards
Hidden Refuge
 


Forum Jump:


Users browsing this thread: 1 Guest(s)

Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - SSDBlaze - VPSlices - Abc-Hosters - Hyper Expert - Shadow Hosting - Bladenode - HostDoc - Hostlease


About Post4VPS

Post4VPS is a forum/destiny where you can Delploy Your Free VPSs just by the Power of Posts.

We Provide VPSs of many locations like Germany,US,Canada,France,London,etc.

We also Provide VPSs of Both Linux and Windows OS.