2012-01-05 103 views
1

我有一個網站使用WordPress的前端&一個CodeWarrior應用程序的'網上商店'後端。 Wordpress結構不在根目錄中,而是位於/wp目錄中。集成Wordpress,Codeigniter和.htaccess

我需要重寫如下一些的.htaccess規則: 我試圖做到以下幾點 -

  1. 如果用戶去www.company.com那麼它對於WP的重寫規則(WordPress的)文件夾
  2. 如果用戶轉到admin.company.com,那麼它會對index.php執行重寫規則(對於Codeigniter應用程序)
  3. 最後一位是mod_rewrite for wordpress URLS所必需的。

我的問題是,我不能因爲使用RewriteBase規則的兩個規則1和規則2的工作 - 任何人都可以建議如何去使用每個規則RewriteBase(例如超過一次)或類似的命令做這個?

RewriteCond %{HTTP_HOST} ^(www.)?company.com$ 
RewriteRule ^(/)?$ wp [L] 

RewriteCond %{HTTP_HOST} ^admin.company.com$ 
RewriteRule index.php [L] 

RewriteBase /wp/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /wp/index.php [L] 

RewriteRule ^(.*)$ /index.php?$1 [L] 

回答

1

如果你有你的根目錄下的笨索引文件,那麼你可能會保留.htaccess文件單獨,只是使用路由文件在你的笨應用。

$subdomain_arr = explode('.', $_SERVER['HTTP_HOST'], 2); //creates the various parts 
$subdomain_name = $subdomain_arr[0]; //assigns the first par 

if ($subdomain_name == 'admin')) { 
    $route['uristring'] = "controller/method"; 
} elseif($subdomain_name == 'www')) { 
    $route['uristring'] = "controller/method"; // in this method, just do a redirect to your /wp folder. 
} 
+0

我試過以下內容: - – Zabs 2012-01-06 09:36:03

+0

你試過了什麼?我的答案?它有效嗎? – Catfish 2012-01-06 15:22:27