Sectorlink
  • 0 Shopping Cart
  • Home
  • Store
    • Cloud Web Hosting
    • Dedicated Servers
    • Site Builder With Hosting
    • Cloud Servers ( VPS )
    • Server Colocation
    • SSL Certificates
    • Email Services
    • Plesk Web Hosting
    • cPanel Web Hosting
    • Register a New Domain
    • Transfer Domains to Us
  • Announcements
  • Knowledgebase
  • Contact Us
  • More
  • Account
    • Login
    • Forgot Password?
  1. Portal Home
  2. Knowledgebase
  3. Development
  4. Redirect non-www to www in Linux (Apache)

  Categories

Client Portal
5
Cloud Web Hosting
34
CloudPod / VPS
1
Co Location
2
Control Panels
20
Dedicated Servers
23
Development
16
Domain Registration
6
E-Mail
14
Frequently Asked Questions
2
Legacy Web Hosting
2
SSL Certificates
2
Website Builder Hosting
2
WordPress
1

  Categories

  Support

My Support Tickets
Announcements
Knowledgebase
Open Ticket

Redirect non-www to www in Linux (Apache) Print

  • 2

Create a file .htaccess in the document root of your site with the following code.  If this file already exists, prepend the following code to it:

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>

 


Was this answer helpful?

Related Articles

Redirect non-SSL to SSL in Windows (IIS) The following code sample will 301-redirect http://www.domainname.com to... How do I redirect my site using a .htaccess file? Note: Applies to Linux hosting accounts only. Create an empty text file using a text editor such... Enable custom error pages on IIS 7 (Windows 2008) and newer Custom error pages can be implemented in IIS 7 (Windows 2008) and newer by placing a web.config... Remotely view error messages on IIS 7 (Windows 2008) and newer When a website page encounters a coding error on a IIS 7 (Windows 2008) or newer hosting server,... Create T-SQL dump of MS SQL data Open Management Studio and connect via your SQL server host name, the database username and...
« Back

  Support

My Support Tickets
Announcements
Knowledgebase
Open Ticket
  • Contact Us
  • Terms of Service

Copyright © 2025 Sectorlink. All Rights Reserved.


Loading...
Loading...

Generate Password

Please enter a number between 8 and 64 for the password length