How to redirect non-www URLs to www

  • Spammers will be banned immediately without warning. Read our Signup Policies here.
  • 🎉 We've Hit 1 MILLION VIEWS in April 2025! 🚀

    We're proud to announce that blackhatforums.net has officially crossed 1,000,000 page views in a single month — April 2025! 🤯

    This milestone is a direct result of your hustle, strategies, and contributions. Whether you're dominating SEO, pushing traffic, or just absorbing knowledge — this is your win. 💪

    👉 Read the Celebration Thread Here

    — The blackhatforums.net Team

romeo

Newbie
Messages
28
Likes
1
Points
3
In order to redirect all of the requests for yourdomain.com to www.yourdomain.com, you should set the appropriate rewrite rule. This can be done by adding the following lines at the beginning of the .htaccess file in your public_html folder:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

From now on, when someone accesses http://yourdomain.com will be redirected to http://www.yourdomain.com.
 

Members online