Php .htaccess帮助-Codeigniter

Php .htaccess帮助-Codeigniter,php,.htaccess,codeigniter,mod-rewrite,rewrite,Php,.htaccess,Codeigniter,Mod Rewrite,Rewrite,我目前有一个.htaccess文件要重写index.php所有的基本URL,exampleexample.com/index.php/home->example.com/home .htacces文件位于mypublic\u html文件夹的根目录中,如下所示: RewriteEngine on RewriteCond $1 !^(index\.php|images|css|adminer|resources|robots\.txt) RewriteRule ^(.*)$ /index.php/

我目前有一个
.htaccess
文件要重写
index.php
所有的基本URL,example
example.com/index.php/home->example.com/home

.htacces
文件位于my
public\u html
文件夹的根目录中,如下所示:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|adminer|resources|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
据我所知,这重写了任何不是图像、css、资源等的
/URL
,指向
index.php

我现在正试图在我的
.htaccess
中添加一条规则,以重写
example.com/forums->fourms.example.com

根据当前规则,当我尝试访问
forums.example.com
时,会收到
500-内部服务器错误。我还尝试了以下方法,但没有成功:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|adminer|resources|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^/forums(.*)
RewriteRule ^forums(.*)$ http://forums.example.com$1 [R=301,L]

如何更改这些规则以允许重定向
index.php
并将
example.com/fourms
重写为
fourms.example.com

今天,我在发布一个问题后,第二次找到了答案:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|resources|forums|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^/forums(.*)
RewriteRule ^forums(.*)$ http://forums.example.com$1 [R=301,L]
我不得不将
/forums
从第一次重写中排除,并在第二次重写中添加