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 630 times since Fri, Nov 26, 2021
The ’Access-Control-Allow-Origin’ header with Giant Apache!
Viewed 784 times since Mon, Oct 19, 2020
Deny direct access to all .php files
Viewed 630 times since Wed, Dec 22, 2021
Deny direct public access to all files in directory
Viewed 517 times since Wed, Dec 22, 2021
The ’Access-Control-Allow-Origin’ header contains multiple values
Viewed 792 times since Mon, Oct 19, 2020