disculpe pero como hago para que si alguien sepe la ip le rediriga al dominio
por ejemplo
pone la ip -> 17.1321.1231.1 -> se vaya a example.com y no se quede en 12-23-1.132

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.

×
1 answer

Hi @proyectszonaentrenamient,

You can achieve this with a rewrite in an htaccess file in your DocumentRoot directory. Go to the folder

/etc/apache2/sites-available

In the folder, you should have a configuration file named 000-default.conf. You will need to be sure that your 000-default.conf file has AllowOverride All set for the DocumentRoot directory so the settings in your htaccess file will be used. Then you will want to create an .htaccess file in that directory with the following (replacing the IP and domain with your own):

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^12\.34\.56\.789$
RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301]

once this is done, make sure the rewrite module is enabled:

a2enmod rewrite

and restart apache

service apache2 restart

Regards,
KFSys

Submit an Answer