[英]codeigniter multiple applications, with wild card sub domains, mod_rewrite remapping sub domains to .php
我有一個結構如下的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將調用從子域重定向到其相應的應用程序env? IE: http : //ggg.mapitusa.com/user/login重定向(無htaccess)到http://mapitusa.com/index.php/ggg/user/login ?
謝謝!
嘗試將以下內容添加到網站根目錄中的.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]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.