Apache URL重写以使所有请求http://example.com/controller 重定向到http://example.com/index.php/controller 不更改url

Apache URL重写以使所有请求http://example.com/controller 重定向到http://example.com/index.php/controller 不更改url,apache,mod-rewrite,codeigniter,url-rewriting,Apache,Mod Rewrite,Codeigniter,Url Rewriting,我希望在不更改url的情况下将所有请求重定向到,我的.htaccess文件如下所示: # Customized error messages. ErrorDocument 404 /index.php # Set the default handler. DirectoryIndex index.php # Various rewrite rules. <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQU

我希望在不更改url的情况下将所有请求重定向到,我的.htaccess文件如下所示:

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]

  RewriteBase /
  RewriteCond %{HTTP_HOST} ^www.example.com [NC]
  RewriteRule ^(.*)$ http://example.com/$1 [R=301] 
</IfModule>
#自定义错误消息。
ErrorDocument 404/index.php
#设置默认处理程序。
DirectoryIndex.php
#各种重写规则。
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]
重写基/
重写cond%{HTTP_HOST}^www.example.com[NC]
重写规则^(.*)$http://example.com/$1[R=301]
不幸的是,这不起作用。将所有请求路由到主控制器,并且url不变。
所有要路由到的请求和url都会在地址栏中更改。

将导致外部重定向的规则放在导致内部重定向的规则之前。因此:

RewriteEngine on
RewriteBase /

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

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

谢谢你的快速回复!我试过了,但我仍然有同样的问题。所有像或(www)这样的查询都会导致默认主页。知道为什么吗?听起来不像是.htaccess问题。我认为您需要处理config/routes.php文件$路线['scaffolding_trigger']=“”;我还应该补充什么?