.htaccess CodeIgniter中的mod_重写、子域和htaccess
现在我正在codeigniter中进行一个webshop项目。 最终,在子域上会有多个Webshop,在主域上会有一个frontpage 它应该是动态的,这样网店就有了自己的子域。 商店信息在数据库中。假设我有一个mysql表,其中包含如下信息:.htaccess CodeIgniter中的mod_重写、子域和htaccess,.htaccess,codeigniter,mod-rewrite,dns,subdomain,.htaccess,Codeigniter,Mod Rewrite,Dns,Subdomain,现在我正在codeigniter中进行一个webshop项目。 最终,在子域上会有多个Webshop,在主域上会有一个frontpage 它应该是动态的,这样网店就有了自己的子域。 商店信息在数据库中。假设我有一个mysql表,其中包含如下信息: 网店:Bobs商店 webshop_子域:bobsshop 等等 现在在一个.htaccess文件中,我想制定一个重写规则,这样bobsshop.mydomain.com将被重写为mydomain.com/bobsshop/,因为我正在使用带有控制
- 网店:Bobs商店
- webshop_子域:bobsshop
- mydomain.com xxx.xxx.xxx.xxx
- *.mydomain.com xxx.xxx.xxx.xxx
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^((?!www\.)(?!mydomain\.com)[^\.]+)\.
RewriteRule ^(.*)$ http://www.mydomain.com/index.php?/%1/$1 [L]
输入URL-
输出URL-
然后,您可以通过以下方式从URL中删除index.php
$config['index\u page']=“index.php”
与$config['index\u page']=“index.php”
在某些情况下,uri_协议的默认设置无法正常工作。要解决此问题,只需在system/application/config/config.php中将
$config['uri\u protocol']]=“AUTO”
替换为$config['uri\u protocol']=“REQUEST\u uri”
,它似乎不起作用。当你进入子域时,最好是一个商店。比如a-shop.mydomain.com。现在不行了。如果我键入a-shop.mydomain.com,它将显示主页,该主页位于mydomain.com上。也许我应该提到,a-shop是codeigniter中的一个动态控制器。我的虚拟主机文件呢?我应该做点什么吗?那么DNS呢?你说动态控制器是什么意思?上面的.htaccess将从a-shop.mydomain.com/foo/bar向mydomain.com/a-shop/foo/bar发送请求,这意味着a-shop是控制器,foo是方法,bar是参数1。您无需触摸虚拟主机或DNS设置,它们看起来很好。
1 RewriteCond %{HTTP_HOST} ^((?!www\.)(?!mydomain\.com)[^\.]+)\.
This condition was met
2 RewriteRule ^(.*)$ http://www.mydomain.com/index.php?/%1/$1 [L]
This rule was met, the new url is http://www.mydomain.com/index.php?/adasd/test
The tests are stopped, using a different host will cause a redirect