-
-
Save farukcam/9d3de4ba89ab7236c5b428d55e5a93c8 to your computer and use it in GitHub Desktop.
NODE.JS app in Apache - force www. and https: sample .htaccess - partialy based on vielhuber/.htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################### | |
# | |
# NODE.JS app running in Apache | |
# sample .htaccess - partialy based on vielhuber/.htaccess | |
# Also rules to enforce www. prefix and https: SSL access | |
# | |
# This file must be on the dir where Apache expects to find the website | |
# The Node App can be anywhere else but must be accessible as explained below. | |
# | |
# ModRewrite must be active on Apache | |
RewriteEngine On | |
# First check if domain starts with www. and add it | |
# then if not using SSL force it | |
RewriteCond %{HTTP_HOST} !^$ | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{HTTPS}s ^on(s)| | |
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
RewriteCond %{HTTPS} off | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE] | |
# Redirect all trafic to NODE.JS server. | |
# It must be running and, in this case, listening to port 60000 | |
RewriteRule ^$ http://127.0.0.1:60000/ [P,L] | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ http://127.0.0.1:60000/$1 [P,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment