how to direct hit by ip to specific page

Discussion in 'Installation/Configuration' started by Andi Achridhan Amdari, Jan 3, 2023.

Tags:
  1. So in some case I want to people hit server IP to change some page instead showing default apache2 default page
    I've try to change /etc/apache2/sites-available/000-default.conf document root to /var/www/clients/client1/web1/web
    but got "Forbidden You don't have permission to access this resource."
    pls help.. how to solve this
     
  2. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    if you're using apache2.. you can put a .httaccess file in /var/www/html/ and put the following in the .htaccess file:

    Code:
    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} 192.16.1.1
    RewriteRule $ https://www.differentwebsiteurl.com [R=301,L]
    
    changing the source ip and target url as required.
    if you wanted to redirect to a url on the same site/vhost, you could change the last line to:
    Code:
    RewriteRule $ /newwebsitedocument.html [R=301,L]
    
    changing the target document as necessary... could be a php script file, wordpress stub etc..

    since you want to change the default apache page, this is the easiest way...
    you could modify the vhost conf to do this, but you'd have to modify the template and put it in the custom folder to make it update safe.
    also, if you wanted to do it to an actual website, you'd have to use the ispconfig website options apache directives area. or change the master template, which would end up applying it to every new site and every existing site after a resync.
     
    ahrasis likes this.
  3. so that just like redirect right?
    in this case.. the web is just for local/vpn and not using domain.. so users can still access the web just using the ip.. without change their etc/hosts
     
  4. I've try to change back /etc/apache2/sites-available/000-default.conf document root to /var/www/html
    but create new .vhost instead to listen the ip 172.1.2.3:80 to web folder page.. but not working
     
  5. I solve it.. by making link between site-enable and site-avaiable
    ln -s /etc/apache2/sites-available/172.1.2.3.vhost /etc/apache2/sites-enabled/200-172.1.2.3.vhost
    the 172.1.2.3.vhost is copy from currentweb.vhost then only change <VirtualHost *:80> to <VirtualHost 172.16.36.137:80>
     

Share This Page