arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#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
Watch this beauty till the end..

#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 Limitless Hosting and Post4VPS for providing me excellent VPS 13!
#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.
[Image: zHHqO5Q.png]
#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".
Watch this beauty till the end..

#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.
Watch this beauty till the end..

#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.
[Image: zHHqO5Q.png]
lockThread Closed 


Possibly Related Threads…
Thread
Author
Replies
Views
Last Post

person_pin_circle Users browsing this thread: 2 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting