Home » Categories » Apache » .htaccess Configuration

.htaccess - how to force “www.” in a generic way?

RewriteEngine On
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]



Ref:
https://stackoverflow.com/questions/4916222/htaccess-how-to-force-www-in-a-generic-way
Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
Allow file directory listing using .htaccess
Viewed 607 times since Fri, Nov 26, 2021
The ’Access-Control-Allow-Origin’ header with Giant Apache!
Viewed 766 times since Mon, Oct 19, 2020
Deny direct access to all .php files
Viewed 600 times since Wed, Dec 22, 2021
The ’Access-Control-Allow-Origin’ header contains multiple values
Viewed 772 times since Mon, Oct 19, 2020
Deny direct public access to all files in directory
Viewed 495 times since Wed, Dec 22, 2021