-1

I need help with .htaccess. I'm using apache.

I want to change my server IP to another one.

Example:

http://127.0.0.1/files/image.png

to

http://192.196.1.1/files/image.png
  • 2
    Welcome to SO, please do share your htaccess file in your question, thank you. – RavinderSingh13 Jan 10 '21 at 02:41
  • I'm not using htaccess file at this moment. – Steve Bonsko Jan 10 '21 at 02:42
  • This is evidently an _internal_ IP address, why do you need to issue an external redirect? Or do you simply want to "change [your] server IP" (no redirect)? However, something like this really shouldn't be done in `.htaccess` (as tagged), since the website itself shouldn't be accessible from both IPs (if it is then you aren't actually _changing_ anything). (?) – MrWhite Jan 10 '21 at 11:56

1 Answers1

2

Could you please try following, written and tested with shown samples.

Please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{HTTP_HOST} 127\.0\.0\.1 
RewriteRule ^ http://192.196.1.1%{REQUEST_URI} [R=301,NE,L]
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93