Rewrite the URL www.domain.com by calling 404 on my page

Ok, so I rewrote the URL on my website, now for some reason it throws a 404 error if I type www.domain.com, if I type domian.com, everything works fine.

DirectoryIndex home.php IndexIgnore * #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] #RewriteRule ^(.*)$ http://%1/directory/$1 [L,R=301] RewriteRule ^home/?$ home.php [NC] RewriteRule ^about/?$ about.php [NC] RewriteRule ^404/?$ 404.php [NC] ErrorDocument 404 http://domain.com/directory/404 

Note. I commented on the first 2 rewrite rules, even if I changed them, it does not affect after loading .htaccess to the server, it looks like it is cached.

For more information, I use the <base> , which is located in embeds.php

 if($_SERVER['REMOTE_ADDR'] == '::1') { echo '<base href="http://localhost/projects/directory/" />'; } else { echo '<base href="http://domain.com/directory/" />'; } 

Directory structure

 Root - home.php about.php -stylesheets default.css -includes embeds.php 404.php .htaccess 

embeds.php included in home.php , about.php , etc., and style sheets, scripts, etc., insert the header along with the <base> in embeds.php

+6
source share
2 answers
 RewriteCond %{HTTP_HOST} ^domain.com$ RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301] 

It should work if it does not go from your DNS or Vhost configuration.

+1
source

This is also a firefox issue that cached my .htaccess file

Here are some useful links that might help other users refer to this question.

Apache - how to disable browser caching while debugging htaccess

Is the htaccess file cached somehow?

+1
source

All Articles