Reputation: 905
Is there a way I can simplify this code so I dont have to check .com and .org separately?
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/mydirectory(/.*)?$ [NC]
RewriteRule ^(.*)$ /mydirectory/$1 [QSA,L]
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.org$ [NC]
RewriteCond %{REQUEST_URI} !^/mydirectory(/.*)?$ [NC]
RewriteRule ^(.*)$ /mydirectory/$1 [QSA,L]
Upvotes: 0
Views: 141
Reputation: 785541
Yes you can take regex help for that. Try this:
RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.(com|org)$ [NC]
RewriteCond %{REQUEST_URI} !^/mydirectory(/.*)?$ [NC]
RewriteRule ^(.*)$ /mydirectory/$1 [L]
Take note of (org|com)
which makes that patter match both .org
and .com
Upvotes: 2