Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force www except for subdomains #83

Open
rEnr3n opened this issue Sep 19, 2017 · 0 comments
Open

Force www except for subdomains #83

rEnr3n opened this issue Sep 19, 2017 · 0 comments

Comments

@rEnr3n
Copy link

rEnr3n commented Sep 19, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant