2012-08-10 17 views
9

私は私の.htaccessファイルに次のような構造を作成したい:Apache htaccessで書き直しする方法はありますか?

If (SITE A DOMAIN or SITE A SUBDOMAIN) { 
    Rewrite this specific way -> /index.php/$1 
} else { 
    Rewrite this specific way -> /directory/www/index.php/$1 
} 

私は以下の私の現在のコードを持っているが、それは約泣き言私のApacheのエラーログと500Sを投げています:[[誤差]

client :: 1] mod_rewrite:内部リダイレクトの最大数に達しました。構成エラーが発生すると想定します。リファラー:

私は間違っているのですか?ありがとう!

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|blog) 

RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC,OR] 
RewriteCond %{HTTP_HOST}^example\.com$ 
RewriteRule .? - [S=1] 
RewriteRule ^(.*)$ /directory/www/index.php/$1 [L] 
RewriteRule .? - [S=1] 
RewriteRule ^(.*)$ /index.php/$1 [L] 

答えて

15

それはちょうど/(一種の混乱読み取るために取得することができます)スキップフラグより条件を使用して除外する含めるために少しクリーナーかもしれません。しかし、リダイレクトループが500を引き起こしているようです。これを試してみてください。

# If (SITE A DOMAIN or SITE A SUBDOMAIN) 
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^example\.com$ [NC] 
# make sure we haven't already rewritten this URI 
RewriteCond %{REQUEST_URI} !/directory/www/index.php 
# don't rewrite if the resource already exists 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# rewrite 
RewriteRule ^(.*)$ /directory/www/index.php/$1 [L] 

# IF !(SITE A DOMAIN or SITE A SUBDOMAIN) 
RewriteCond %{HTTP_HOST} !^subdomain\.example\.com$ [NC] 
RewriteCond %{HTTP_HOST} !^example\.com$ [NC] 
# make sure we haven't already rewritten this URI 
RewriteCond %{REQUEST_URI} !/index.php 
# don't rewrite if the resource already exists 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# rewrite 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

ありがとうございました! –

関連する問題