Skip to content

Force www except for subdomains #83

Open
@rEnr3n

Description

@rEnr3n

I found this rule here - https://stackoverflow.com/questions/20631015/force-www-in-htaccess-except-all-subdomains

RewriteEngine On
RewriteCond %{HTTP_HOST} ^[0-9a-zA-Z-]+\.[a-zA-Z]{2,}$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

I get a double slash at the end of the url if i type in an address like server.lan/

So I changed it a bit to look like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^[0-9a-zA-Z-]+\.[a-zA-Z]{2,}$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

I don't know if it's good though. I made a quick test and it looks ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions