我有一个网站使用wordpress作为前端和&用于'网店'后端的Codeigniter应用程序。 Wordpress结构不在根目录中,而是在/wp
目录中。
我需要一些重写如下的.htaccess规则: 我正在尝试执行以下操作 -
我遇到的问题是我无法同时使用规则1和规则2,因为使用了RewriteBase规则 - 任何人都可以建议如何使用每个规则的RewriteBase(例如不止一次)或类似的命令来执行此操作吗? / p>
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]
答案 0 :(得分:1)
如果你的root中有codeigniter索引文件,那么你可以单独留下.htaccess文件,只需使用你的codeigniter应用程序中的routes文件。
$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.
}