Home > Software design >  Why my new website domain sometimes directed me to the old webpage
Why my new website domain sometimes directed me to the old webpage

Time:04-06

I have a website that was hosted in n*agahoster, which already expired (with active status) since our company didn't want to use the domain example.com and instead change the hosting place to a government's server which resulting to a new domain example.gov.xx

The procedure was not hard, since there is someone who handle the server, and I just gave the backup files (the public_html as well as the database) from old hosting place. Everything went smoothly, until I tried to access the new domain (example.gov.xx), instead of showing me the actual webpage, it directed me to old domain (example.com) which already expired and can't be access. This only happened on a certain time though, if I keep refreshing the web, using different browser, or try to access it later, it will show the correct domain as well as the webpage, BUT it only appeared in my own PC, and if my friends want to access the new domain (example.gov.xx) it will still direct them to the old webpage (example.com) and they have to keep on trying or use different browser, to actually access the correct new domain.

Why can this happen? I already change the link of the old domain to the new domain in my index.php file. Is there anything that I should add or change? Is it the .htaccess file?

v3/index.php

<script>
     setTimeout(function(){
       window.location.href = 'http://example.gov.xx/v3/public/'; //The old one is example.com/v3/public
       // window.location.href = 'http://localhost/folder/v3/public/?SI-xxxxxxxxx=YWN0PWhvbWU='; //ignore this
     }, 10000);
</script>

.htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

CodePudding user response:

find and replace in file also DB old domain name to new domain name manualy. also from social media links use htaccess to redirect old url to new url.

CodePudding user response:

If this is only happening for your computer there are two possibilities:

  1. Your browser has the redirect cached. Browsers aggressively cache redirects. So if you tried to access the new site when it actually was redirecting, your browser will remember that. You need to clear your browser cache before testing again.

  2. The DNS isn't correct on your local machine. This is often caused by having entries in /etc/hosts (or c:\windows\system32\drivers\etc\hosts on Windows) that you created for development that point the new domain to the IP address of the old host.

  • Related