Keep current .htaccess file but add subdomain handler

Keep current .htaccess file but add subdomain handler - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, wordpress, subdomain, , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


Below is my current .htaccess file. I want to add a method by which I can conduct a simple pass-through if someone hits my subdomain. My current .htaccess is designed to grab any one who comes to my site and force them to the SSL version.



I now need to allow someone to come to my site and hit a subdomain mysite2.mysupercoolserverhere.com without being passed to SSL or generally bothered by any of my WordPress-centric .htaccess stuff.



RewriteEngine On
RewriteCond %SERVER_PORT 80
RewriteRule ^(.*)$ https://mysupercoolserverhere.com/$1 [R,L]

RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %REQUEST_FILENAME -f [OR]
RewriteCond %REQUEST_FILENAME -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/
)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


I attempted to add:



RewriteRule ^(mysite2.*/)$ - [PT]


But this did not work. Can someone please tell me how to fix/add my Rewrite Rule so that I can let users hit my subdomain without being forced to my TLD?



I need to fix my .htaccess file so my WordPress site continues to work as intended but allow users to surf over to my subdomain without being affected by my current .htaccess file.


Solution :

I added a new rewrite condition:



RewriteCond %HTTP_HOST ^www.domain.com$


At the very top of my .htaccess file. By adding the condition that all the below only works with my TLD I no longer have issues with it grabbing my subdomains.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect