How to fix localhost redirecting to www.localhost.com
I have got several request that when I browse the site on http://localhost/PROJECTNAME. Then it automatically redirect it to www.localhost.com/PROJECTNAME . These kind of issue can be available with almost all CMS based project like Drupal, Prestashop, Joomla, WordPress, CS cart, Magento etc..
If you are also facing this issue on your localhost then you just need to follow the instruction.
*. Open your .htaccess file (Usually found on root of the project) and comment below lines by placing # at the beginning of the file.
RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule ^ <a href="http://www." target="_blank">http://www.</a>%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
That means simply replace these code with below code
#RewriteCond %{HTTP_HOST} !^www. [NC] #RewriteRule ^ <a href="http://www." target="_blank">http://www.</a>%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Now save your .htaccess file and retry with browsing your project.
Chandra Shekhar
Latest posts by Chandra Shekhar (see all)
- Best practices for micro service design - January 23, 2022
- Spring Boot - January 23, 2022
- Java - January 23, 2022
Recent Comments