Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC] RewriteRule ^/?(.*) http://subdomain.domain.com/wordpress/$1 [L] RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC]
How do I write the code to only be valid for one specific subdomain.
For ex.
subdomain1.domain.com --> subdomain.domain.com/wordpress/
subdomain2.domain.com --> do nothing
How do I add to the regex that the URL also must contain the word "subdomain1"
(and not have the wordpress folder)?
The idea here is if /wordpress/ is NOT in the REQUEST_URI, then then add it.
What you should escape is the two literal periods. Here they aren't crucial, because a request for "subdomainzdomainxcom" would never reach you, but you should get in the habit anyway.
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wordpress/ [NC]
RewriteRule ^/?(.*) http://subdomain.domain.com/wordpress/$1 [R=301,L]
The problem is that, when requesting user2.domain.com, the result is always being sent to user1.domain.com