1

I have installed Apache, PHP, Mysql in ubuntu system. I have changed the port of apache server 80 to 802 in httpd.conf file.

I am accessing localhost from the below URL successfully.

http://localhost:802/

But the thing I want to access the localhost without using port number in the URL. Where I need to change for this.

Please suggest.

AMit SiNgh
  • 325
  • 4
  • 17
  • 3
    Possible duplicate of [How to remove port number from http://localhost:8123 to use as http://localhost?](http://stackoverflow.com/questions/13155529/how-to-remove-port-number-from-http-localhost8123-to-use-as-http-localhost) – Dev Man Feb 18 '17 at 11:48
  • Why did you change the port number in the first place – RiggsFolly Feb 18 '17 at 11:57
  • If you make Apache listen on a non-standard port (i.e. not 80) then you have to use the port number on all urls – RiggsFolly Feb 18 '17 at 12:00

1 Answers1

0

Where I need to change for this.

In httpd.conf where you set the port number to 802, set it back to 80.

HTTP operates on port 80 by default, and web browsers use that default by convention. Since you have changed that default, you need to specify the port in the address. Otherwise the web browser will attempt to connect to port 80 and won't find your server.

David
  • 208,112
  • 36
  • 198
  • 279
  • Isn't there any solution to make it possible without set it back to 80 ? – AMit SiNgh Feb 18 '17 at 11:56
  • @amitsingh: I suppose you could run a server on port 80 which does nothing but forward the user to port 802. Of course then, once forwarded, the URL will once again have the "802" in it. – David Feb 18 '17 at 11:58
  • can you please explain how can I forward a user to 802. :) – AMit SiNgh Feb 18 '17 at 12:00
  • @amitsingh: It could be a simple rewrite rule in an `.htaccess` file in the root of the site on port 80: `Redirect 301 / http://localhost:802/` A Google search for "apache redirect" or "httpd.conf redirect" can find lots of examples, including more options here: http://www.yolinux.com/TUTORIALS/ApacheRedirect.html Though honestly, this seems like far more trouble than it's worth. If you want a site on port 80 to always forward the user to port 802, why not just run the site on port 80 in the first place? – David Feb 18 '17 at 12:05