2012-10-28 18 views
1

我使用.htaccess友好的URL,但我有一個問題。我的子域store.domain.com重定向到「/」但默認文件是「store.php」,domain.com重定向到「/」,默認文件是「index.php」如何使用,如果在.htaccess

我需要使用if,for示例

<If host == 'store.domain.com'> 
store rewrite rules 
<If host == 'domain.com'> 
other rewrite rules different of store 
</if> 

我如何在.htaccess中?

我的.htaccess:


IndexIgnore * 

Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/


RewriteRule ^([a-zA-Z0-9_-]+)$ store.php?page=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/$ store.php?page=$1 

RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1 

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&action=$2 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&action=$2 

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ store.php?page=$1&action=$2 
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ store.php?page=$1&action=$2 

回答

2

請在下次發佈有關堆棧溢出的問題之前,嘗試再研究一下您的問題。對您的問題進行簡單的網絡搜索可以獲得RewriteCond報表。然後你可以參考Apache mod_rewrite documentation

本文檔會導致你的結果,如:

RewriteCond %{HTTP_HOST} ^store.example.com$ 
RewriteRule ^([a-zA-Z0-9_-]+)/?$ store.php?page=$1 
0

this link看看。它有關於如何使用該指令的信息。