【问题标题】:Integrating Wordpress, Codeigniter & .htaccess集成 Wordpress、Codeigniter 和 .htaccess
【发布时间】:2012-02-03 11:12:04
【问题描述】:

我有一个网站,它使用 wordpress 作为前端和一个 Codeigniter 应用作为“网店”后端。 Wordpress 结构不在根目录中,而是在/wp 目录中。

我需要一些重写如下的 .htaccess 规则: 我正在尝试执行以下操作 -

  1. 如果用户访问 www.company.com,那么它会为 wp (wordpress) 文件夹执行重写规则
  2. 如果用户访问 admin.company.com,那么它会对 index.php 执行重写规则(对于 Codeigniter 应用程序)
  3. wordpress URLS 的 mod_rewrite 需要最后一位。

我遇到的问题是,由于使用了 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]

【问题讨论】:

    标签: wordpress .htaccess codeigniter


    【解决方案1】:

    如果您的根目录中有 codeigniter 索引文件,那么您可以不理会 .htaccess 文件,只在您的 codeigniter 应用程序中使用路由文件。

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

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 2020-12-08
      • 1970-01-01
      • 2013-07-23
      • 2011-08-01
      • 2020-12-25
      • 2011-06-04
      • 1970-01-01
      • 2012-04-02
      相关资源
      最近更新 更多