WEBProject
WEBProject

Reputation: 1335

.htaccess - affects all subdomains, how to exclude?

I have the following code:

RewriteEngine on 
#Options +FollowSymLinks 

RewriteCond %{HTTP_HOST} ^raal.co.il
RewriteRule (.*) http://www.raal.co.il/$1 [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|JPG|png|css|php|js|html|htm|psd|rar|htc)$
RewriteRule ^(.*)$ index.php?a=$1 [L]

but then when i create subdomains, i get an error due to this code.

I want - fb.raal.co.il - to not be affected by the .htaccess of the main path.

i've tried adding something like this to the main .htaccess:

RewriteCond %{HTTP_HOST} ^fb\.raal\.co\.il
RewriteRule (.*) http://fb.raal.co.il/$1

but it wont work ..

Upvotes: 0

Views: 1976

Answers (1)

camel
camel

Reputation: 110

just negate (!) that you dont want to redirect fb

RewriteCond %{HTTP_HOST} ^raal\.co\.il
RewriteCond %{HTTP_HOST} !^fb\.raal\.co\.il
RewriteRule (.*) http://www.raal.co.il/$1 [R=301,L]

You can use multiple conditions (RewriteCond) for just one RewriteRule

and use \. instead of .

RewriteCond %{HTTP_HOST} ^raal\.co\.il

dot is a one character in regex

Upvotes: 3

Related Questions