Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: Anoni1337 on March 28, 2020, 07:29:43 PM

Title: Redirecting from IP DNS To Domain
Post by: Anoni1337 on March 28, 2020, 07:29:43 PM
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
Title: Re: Redirecting from IP DNS To Domain
Post by: MobileCS on March 28, 2020, 09:19:37 PM
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.
Title: Re: Redirecting from IP DNS To Domain
Post by: Anoni1337 on March 29, 2020, 02:17:27 AM
There was no that file but I created it,added same lines but it didn't work sadly

https://prnt.sc/ropgbb
Title: Re: Redirecting from IP DNS To Domain
Post by: MobileCS on March 29, 2020, 09:17:23 PM
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.
Title: Re: Redirecting from IP DNS To Domain
Post by: Anoni1337 on March 30, 2020, 03:50:01 AM
Well I could not find solution in Apache so I switched to to nginx and found solution there