Redirecting from IP DNS To Domain

Started by Anoni1337, March 28, 2020, 07:29:43 PM

Previous topic - Next topic

Anoni1337

Well I got VPS and I still can access my website and forum subdirectory thru IP,I tried couple of things like this,but didn't help

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^42\.145\.51\.105$
RewriteRule ^(.*)$ http://domain-mine.com/$1 [L,R=301]


a2enmod rewrite  systemctl restart apache2

MobileCS

You probably don't have permission to make those changes in the .htaccess file.

If you have SSH access, I would recommend to throw that configuration in your domains Apache configuration file.

Just look for a directory like "/etc/apache2/sites-available". In there, you should see a file like "domain-mine.com.conf".

If not, you could create the file and then just throw your 4 lines of code in it - and restart apache (systemctl restart apache2) and see if that solves your issue.

Anoni1337

There was no that file but I created it,added same lines but it didn't work sadly

https://prnt.sc/ropgbb

MobileCS

Ok, delete the file you created and edit the "000-default.conf" file and look for the line that contains "AllowOverride".

I'm assuming if it exists, it's set to "None"? If it's set to anything else, do nothing and let me know what it's set too.

If it's set to "None", change it to "FileInfo" - and add the .htaccess file back to website's directory that contains your code and reboot Apache.

Anoni1337

#4
Well I could not find solution in Apache so I switched to to nginx and found solution there

Advertisement: