Php mod_重写codeigniter中的子域和clen url
我想我的域名是www.domain.com 我有一个文件系统Php mod_重写codeigniter中的子域和clen url,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我想我的域名是www.domain.com 我有一个文件系统 public_html |----ds |--application |--cache |--controller ... |--css |--image |--system |--index.php |----zs |----fd public_htm
public_html
|----ds
|--application
|--cache
|--controller
...
|--css
|--image
|--system
|--index.php
|----zs
|----fd
public_html是根目录
我在.htacess中使用以下条件编码::
1 ds目录是子域。当URL为ds.domain.com时。它在www.domain.com/ds/index.php中映射文件路径/
2我想清理URL表单www.domain.com/ds/index.php/translate/paintext示例ds.domain.com/translate/paintext清理URL的完整URL
如何在.htacess中编码
/********************************************************************/
我将.htacess放在/ds文件夹中,并尝试编码:
#subdomain to subdirectory
RewriteCond %{HTTP_HOST} ^www.domain.com/ds/
RewriteRule ^(.*)$ http://ds.domain.com/$1 [L,R=301]
#clean URL from codeigniter
RewriteCond $1 !^(index\.php|lib|css|image)
RewriteRule ^(.*)$ index.php/$1 [L]
出什么问题了???至少有一件事是你的HTTP\U主机出了问题。该变量是主机名,主机名中不包含URL路径信息。因此,www.domain.com/ds/将永远不会作为主机名存在。将其更改为:
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^ds/(.*)$ http://ds.domain.com/$1 [L,R=301]
第二个问题看起来不错。但是,如果要将/index.php的请求重定向到没有index.php部分的新URL,则需要一个新规则:
RewriteCond %{THE_REQUEST} \ /+index\.php/
RewriteRule ^index.php/(.*)$ /$1 [L,R=301]