âš ī¸ Warning âš ī¸ Deprecated Code! This video tutorial contains outdated code.
💡 If you wish to update it, any AI assistant will update the code for you in seconds.

Force www Into URL

Published : November 22, 2014   •   Last Edited : November 24, 2025   •   Author : Adam Khoury

In this quick web development tip we discuss the apache method of forcing script connection in case the www is missing from a URL that requires it for script connection and session handling.

.htaccess
RewriteEngine on
# Make all requests have the www. in the URL
RewriteCond %{HTTP_HOST} ^websitename\.com
RewriteRule ^(.*)$ http://www.websitename.com/$1 [R=permanent,L]