altariamx2003
asked on
How to add a bypass rules for my sudomains in my htacess
I have my domaing "www.myserver.com" and I got customized my ".htaccess" file with the following rewrite rules:
This set of lines allow me:
1.- redirect all calls of "http://" to "https://"
2.- redirect all calls of non "www" to "www"
I wanna know how to bybass of this rules using rewrite rules, subdomains in the same server? I tried with RewriteCond %{HTTP_HOST} !subdomain\.myserver1\.com $ [NC], but after I add that line I need to comment
Is there a way to add a bypass for my subdomains in my htaccess?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/oculto/larespuesta.php$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www.myserver.com$ [NC]
RewriteRule ^(.*)$ https://www.myserver.com/$1 [L,R=301]
This set of lines allow me:
1.- redirect all calls of "http://" to "https://"
2.- redirect all calls of non "www" to "www"
I wanna know how to bybass of this rules using rewrite rules, subdomains in the same server? I tried with RewriteCond %{HTTP_HOST} !subdomain\.myserver1\.com
RewriteCond %{HTTP_HOST} !^www.myserver.com$ [NC]
RewriteRule ^(.*)$ https://www.myserver.com/$1 [L,R=301]
Is there a way to add a bypass for my subdomains in my htaccess?
ASKER
Let me check how to try your solution because we have our server with hostgator all subdmains are created by the cpanel from hostgator
About my question I found the solution by myself
The following code redirect all domains from non-www to www and http to https and excludes all subdomains
Thx anyway for your time
About my question I found the solution by myself
The following code redirect all domains from non-www to www and http to https and excludes all subdomains
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Thx anyway for your time
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx to David to take time to answer me
You're welcome!
Just split your host record Apache config files. Almost ever Linux Distro does this now.
So you'll have one /etc/apache2/sites-availab
Then another file like /etc/apache2/sites-availab
Each host .conf file will contain a ServerName stanza which matches only that one host... like...
Open in new window
This approach allows Apache to run faster + be far easier to maintain, than if you somehow... accept all hosts in one config file + then use what you're calling bypass .htaccess rules for subdomains.
Tip: Your example suggests you aren't really using subdomains, instead you're using folder installs for some code.
Folder installs != Subdomains.
Subdomains will take the form of $host.myserver.com where $host is the subdomain name.