整合字preSS,codeigniter和放大器;的.htaccess [英] Integrating Wordpress, Codeigniter & .htaccess

查看:93
本文介绍了整合字preSS,codeigniter和放大器;的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用字preSS的前端和功放站点;一个codeigniter应用程序的网上商店后端。在Word preSS结构不是根,而是在 / WP 目录。

我需要一些改写如下的.htaccess规则: 我试图做到以下几点 -

  1. 如果用户去那么www.company.com的它重写规则的WP(字preSS)文件夹
  2. 如果用户去admin.company.com那么它重写规则的index.php文件(为codeigniter应用程序)
  3. 在最后位是必需的mod_rewrite的字preSS的URL。

我的问题是,我不能因为所使用的RewriteBase规则的两个规则1和规则2的工作 - 任何人都可以建议如何去使用的RewriteBase按规则(如超过一次)或类似的命令来做到这一点? / P>

 的RewriteCond%{HTTP_HOST} ^(WWW)?company.com $
重写规则^(/)?$ WP [L]

的RewriteCond%{HTTP_HOST} ^ admin.company.com $
重写规则的index.php [L]

的RewriteBase / WP /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。 /wp/index.php [L]

重写规则^(。*)$ /index.php?$1 [L]
 

解决方案

如果你有你的根目录下的codeigniter索引文件,那么你可能会保留.htaccess文件孤单,只是使用的路由文件中codeigniter应用程序。

  $ subdomain_arr =爆炸(,$ _ SERVER ['HTTP_HOST'],2'。'); //创建的各个部分
$ subdomain_name = $ subdomain_arr [0]; //指定第一杆

如果($ subdomain_name =='管理员')){
    $航线['uriString中'] =控制器/法;
} ELSEIF($ subdomain_name =='WWW')){
    $航线['uriString中'] =控制器/法; //这个方法,只是做一个重定向到/ WP文件夹。
}
 

I have a site that uses wordpress for the frontend & a Codeigniter app for a 'webshop' backend. The Wordpress structure isn't in the root, rather it is in the /wp directory.

I require some .htaccess rules that rewrite as follows: I am trying to do the following -

  1. if users goes to www.company.com then it does the rewrite rule for the wp (wordpress) folder
  2. if users goes to admin.company.com then it does the rewrite rule to the index.php (for the Codeigniter app)
  3. The final bit is required for the mod_rewrite for wordpress URLS.

The problem I have is that I cannot get both rule 1 and rule 2 working because of RewriteBase rule used - can anyone suggest how to get to use RewriteBase per rule (eg more than once) or similar command to do this?

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]

解决方案

If you have the codeigniter index file in your root, then you can probably leave the .htaccess file alone and just use the routes file in your codeigniter app.

$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.
}

这篇关于整合字preSS,codeigniter和放大器;的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆