Skip to content
No results
  • The journey to better code
  • Articles
  • Tools
  • Projects
  • About
  • Contact
    • Thank you for your message
draghici.net
  • All articles
  • About
  • Contact
draghici.net

Redirect non-www to www using .htaccess

  • Cristi DraghiciCristi Draghici
  • April 24, 2014
  • Programming / Development

The code below added at the begining of the .htaccess file, will redirect non-www urls to corespondent www, as expected:

# BEGIN nowww
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END nowww
# Apache# Wordpress
Previous Post verysimplecaching
Next Post Starfish PHP framework new objects

Categories

  • Everything else
  • Programming / Development
  • News and fun facts
  • Useful tools
  • My projects

Tags

Android Apache application Bootstrap css digitalocean docker dotenv editors git Github hidden hosting html javascript jenkins jest jquery json laravel Linux macOS mysql node.js npm nvm ohmyzsh online openlayers parser php postgres raspberry pi react redux SlimPHP ssh Starfish Ubuntu Virtualmin Vue.js webmin website Windows Wordpress

A quick note

I post here articles that I found interesting, solutions to problems I have encountered and last but not least, display information about my projects and achievements.

Around the web

draghici.net © 2006 - 2023  - Most of the rights reserved