Using htaccess to redirect domain without http
A very simple problem made me to sweat a lot. I have a site where users post their website link and most of them are so dumb and just wont put http:// in their domain and they submit just like www.domain.com.
If the link goes live in my website it wont get redirected and merely 404 file not found error pops up and the URL looks like http://mysite.com/www.domain.com
i know i could check http with regular expressions in php but was just so lazy to do that and this one magic line in .htaccess file solved my problem
RewriteRule ^www\.(.*)$ http://www.$1 [r=301,L]
This will redirect any domain without http like
http://mysite.com/www.domain.com -> http://www.domain.com
I hope this helps if your site is having the same problem.
Similar Posts:
- PHP – How to get domain name from URL?
- Affiliate Hide v1.0 – Free WordPress plugin to Hide & Redirect Affiliate Links
- Fix -> PHP files are downloading when viewed in Browser
- Affiliate Hide – Free wordpress plugin to redirect affiliate links!
- Domain with WWW not resolving problem!
- CPU Exceeded Error on a New Host
- how to change default homepage with htaccess?
- Fix – error occured while processing this directive – shtml 500 server error
- WordPress Problem – Missing Images with Plain Text Only!
- Problem with Custom rewrite rule in WordPress


July 6, 2011
In all honesty, I just function knows that Rosewater relaxes plus energizes the thought process.