codeigniter 多个应用程序,带有通配符子域,mod_rewrite 将子域重新映射到 .php

发布于 2025-01-05 16:07:14 字数 844 浏览 2 评论 0原文

我有一个 codeigniter 项目,结构如下:

httpdocs/
  /application/
    /ggg/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
    /sgaz/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
    /index/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
  /system/
  index.php

我正在尝试重新编写一个通配符子域以映射到其各自的应用程序。只是不知道如何解决这个问题。

我知道您可以创建多个应用程序并为每个应用程序使用多个 (.*).php 文件(即:ggg.php、sgaz.php、index.php)。但是是否可以有一个单独的index.php 文件并使用mod_rewrite 将调用从子域重定向到其各自的应用程序环境? IE: http://ggg.mapitusa.com/user/login 重定向(不带 htaccess)到http://mapitusa.com/index.php/ggg/user/login

谢谢!

I have a codeigniter project structured as so:

httpdocs/
  /application/
    /ggg/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
    /sgaz/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
    /index/
      config/
      controllers/
      models/
      libraries/
      views/
      ...
  /system/
  index.php

I am trying to re write a wildcard sub domain to map to its respective application.. Just not sure how to go about this.

I know you can create multiple applications and use multiple (.*).php files for each application (IE: ggg.php, sgaz.php, index.php). But Is it possible have a single index.php file and use mod_rewrite to redirect calls from a sub domain to its respective application env? IE: http://ggg.mapitusa.com/user/login redirects (without htaccess) to http://mapitusa.com/index.php/ggg/user/login?

Thanks!

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

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

发布评论

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

评论(1

动听の歌 2025-01-12 16:07:16

尝试将以下内容添加到站点根目录中的 .htaccess 文件中。

RewriteEngine on
RewriteBase / 

RewriteCond %{HTTP_HOST} ^([^\.]+)\.mapitusa\.com$ [NC] 
#if not existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
#rewrite to index.php
RewriteRule ^ index.php/%1%REQUEST_URI] [L] 

如果您希望地址栏中的 URL 更改为 http://mapitusa.com/index.php/ggg/user/login?,请将上面的 RewriteRule 替换为

RewriteRule ^ http://mapitusa.com/index.php/%1%REQUEST_URI] [L,R=301] 

Try adding the following to the .htaccess file in the root directory of your site.

RewriteEngine on
RewriteBase / 

RewriteCond %{HTTP_HOST} ^([^\.]+)\.mapitusa\.com$ [NC] 
#if not existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
#rewrite to index.php
RewriteRule ^ index.php/%1%REQUEST_URI] [L] 

If you want the URL in the address bar to change to http://mapitusa.com/index.php/ggg/user/login?, replace the RewriteRule above with

RewriteRule ^ http://mapitusa.com/index.php/%1%REQUEST_URI] [L,R=301] 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文