How to redirect local apache ip to domain name

Posted August 13, 2021 121 views

I want to see how to redirect localhost or local IP to a domain name locally… I have a Apache web page hosted locally and I want people in my LAN to access it via something like instead of my IP… Any help??

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @binukpremaratne,

You need to create a redirect in your Apache Configuration file for your IP/default config.

This is not a standart setup so you won’t be able to find the exact tutorial. Having said that, you should be able to cdit the VirtualHost file of your local IP config to something like that:


    RewriteCond %{SERVER_NAME}
    RewriteRule /(.*)$1 [R=301,L]


Alternatively, you can create an .htaccess file in the folder your app is at and have it redirect to a domain name.

Have in mind that most probably redirecting it to a Domain won’t work as you expect as it would require a lot of configuring to make the Domain work for LAN network the way you want.