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]

# 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.


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.