This content originally appeared on Bram.us and was authored by Bramus!
Because I have to look this up from time to time, a note to myself: Add the contents below to your .htaccess
to have Apache trim the www.
prefix from URLs while preserving the rest of the URL (domain name, querystring, etc).
RewriteEngine On
# Trim www prefix
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
~
Thank me with a coffee.
I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.
This content originally appeared on Bram.us and was authored by Bramus!
Bramus! | Sciencx (2021-02-15T12:32:52+00:00) Apache .htaccess trim www. prefix from domain name. Retrieved from https://www.scien.cx/2021/02/15/apache-htaccess-trim-www-prefix-from-domain-name/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.