---
title: "Rewrite URL www.domain.com causing 404 on my page"  
description: "Rewrite URL www.domain.com causing 404 on my page"  
author: "Anonymous User"  
published: 2013-04-10  
updated: 2013-04-15  
canonical: https://www.mindstick.com/forum/751/rewrite-url-www-domain-com-causing-404-on-my-page  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Rewrite URL www.domain.com causing 404 on my page

Hi Everyone!\
Ok so I've rewrited URL in my [website](https://www.mindstick.com/articles/13110/why-copywriting-is-crucial-for-new-website-build), now for some reason, it is throwing [404 error](https://www.mindstick.com/forum/156273/what-is-a-404-error) if I type www.domain.com, if I type domian.com, everything [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why).\
DirectoryIndex home.php\
IndexIgnore *#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]#RewriteRule ^(.*)$ http://%1/[directory](https://www.mindstick.com/forum/226/how-to-get-application-directory-using-c-sharp-csharp)/$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/404Note: I've commented the 1st 2 rewrite [rules](https://www.mindstick.com/articles/43901/blackjack-rules) as even If I change them it doesn't [effect](https://yourviews.mindstick.com/view/81363/coronavirus-effect-on-american-farms-is-severe) after uploading .htaccess to [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over), feels like it's cached.\
Additional Info, am using <base> tag which is 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](https://www.mindstick.com/articles/23258/choose-your-business-structure-wisely)\
Root - home.php about.php -stylesheets default.css -includes embeds.php 404.php .htaccessembeds.php is included in home.php, about.php etc, and stylesheets, scripts etc, inshort the head [section](https://yourviews.mindstick.com/view/297/reservation-for-economically-weaker-section) along with <base> tag are in embeds.php\
Thanks you in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!\

## Replies

### Reply by AVADHESH PATEL

Hi Chinto!\
Try as below\
RewriteCond %{HTTP_HOST} ^domain.com$RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]\
It should work, if it dosn't it comes from your DNS, or Vhost configuration.


---

Original Source: https://www.mindstick.com/forum/751/rewrite-url-www-domain-com-causing-404-on-my-page

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
