.htaccess codeigniter 多个域

发布于 2024-09-24 00:14:53 字数 393 浏览 9 评论 0原文

我想知道是否可以组织 CodeIgniter 安装的以下结构:

- Main folder
-- codeigniter
-- images
-- site1-application
-- site2-application
-- site1-index.php
-- site2-index.php

主要思想是在多个 Web 中使用相同的 imagescodeigniter 文件夹站点以便于维护。

目前,我确实有两个网站驻留在两个标准安装中,并且我无法共享图像文件夹,也无法在多个网站上同时更新系统库。

我对 .htaccess 文件进行了一些操作,但我没有运气:(

提前致谢!

I'd like to know if it is possible to organize the following structure of the CodeIgniter installation:

- Main folder
-- codeigniter
-- images
-- site1-application
-- site2-application
-- site1-index.php
-- site2-index.php

The main idea is to use the same images and codeigniter folder across the multiple web sites for easier maintanance.

For now I do have two web sites that are resides in two standard installations and I'm unable to share the images folder nor to update system libraries simulaneously at multiple web sites.

I've played alittle with the .htaccess file, but no luck for me :(

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月野兔 2024-10-01 00:14:53

默认推荐的 CodeIgniter .htaccess 文件:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteRule ^$ /index.php [L]
</IfModule>

根据您的目的调整 CI .htaccess 文件(您知道,一年太晚了):

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Check for Domain 1 with a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^(.*)$ /site1-index.php/$1 [L]
  # Check for Domain 1 without a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^$ /site1-index.php [L]

  # Check for Domain 2 with a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^(.*)$ /site2-index.php/$1 [L]
  # Check for Domain 2 without a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^$ /site2-index.php [L]
</IfModule>

Default recommended CodeIgniter .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteRule ^$ /index.php [L]
</IfModule>

Tweaked CI .htaccess file for your purposes (you know, a year too late):

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  #CodeIgniter
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Check for Domain 1 with a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^(.*)$ /site1-index.php/$1 [L]
  # Check for Domain 1 without a path
  RewriteCond %{HTTP_HOST} domain-1.com
  RewriteRule ^$ /site1-index.php [L]

  # Check for Domain 2 with a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^(.*)$ /site2-index.php/$1 [L]
  # Check for Domain 2 without a path
  RewriteCond %{HTTP_HOST} domain-2.com
  RewriteRule ^$ /site2-index.php [L]
</IfModule>
私野 2024-10-01 00:14:53

是的,这是可能的。

使用 .htaccess 将所有流量从一个域定向到 site1-index.php,将所有流量从另一个域定向到 site2-index.php。

CI 应用程序和系统文件夹的位置在 *-index.php 文件中设置。

Yes, it's possible.

Use .htaccess to direct all trafic from one domain to site1-index.php and all traffic from another domain to site2-index.php.

The location of CI Application and System folders is set in the *-index.php files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文