CodeIgniter关于www.CNAME和index.php的URL/URI

CodeIgniter关于www.CNAME和index.php的URL/URI,php,.htaccess,codeigniter,url-rewriting,uri,Php,.htaccess,Codeigniter,Url Rewriting,Uri,我目前在.htaccess中有以下内容: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 当我键入不带www前缀的

我目前在.htaccess中有以下内容:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
当我键入不带www前缀的域名时:

[我在URL栏中键入的内容=>它最终会变成什么]

example.com => http://www.example.com/ == GOOD!
如果我输入:

www.example.com/register => http://www.example.com/register == GOOD!
example.com/register => http://www.example.com/index.php/register == BAD!
但当我输入时:

www.example.com/register => http://www.example.com/register == GOOD!
example.com/register => http://www.example.com/index.php/register == BAD!
如何删除所有角落案例的index.php部分?特别是最后一个…

请尝试此代码

# First add the www to URL
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

# The remove the index.php from URL
RewriteCond $1 !^(index\.php|ref_doc|media|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我想订货很重要