.htaccess htaccess 301重定向不工作

.htaccess htaccess 301重定向不工作,.htaccess,codeigniter,.htaccess,Codeigniter,我正在尝试向codeigniter站点的.htaccess文件添加一个简单的301规则 redirect 301 /newsletter http://sub.domain.com/newsletters/may2010 当我访问时,重定向转到 http://sub.domain.com/newsletters/may2010/?/newsletter 我不确定?/时事通讯是从哪里来的。完整.htaccess文件: <IfModule mod_rewrite.c> Rew

我正在尝试向codeigniter站点的.htaccess文件添加一个简单的301规则

redirect 301 /newsletter http://sub.domain.com/newsletters/may2010
当我访问时,重定向转到

http://sub.domain.com/newsletters/may2010/?/newsletter
我不确定?/时事通讯是从哪里来的。完整.htaccess文件:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /    

    redirect 301 /newsletter http://sub.domain.com/newsletters/may2010

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>



<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

#####################################################
# CONFIGURE media caching
#
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>
#
#####################################################

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

重新启动发动机
重写基/
重定向301/时事通讯http://sub.domain.com/newsletters/may2010
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
#####################################################
#配置媒体缓存
#
标题未设置ETag
FileTag无
上次修改未设置的标题
标题集过期“2012年12月21日星期五00:00:00 GMT”
标题集缓存控制“公共,无转换”
#
#####################################################
SetOutputFilter放气

我该怎么解决这个问题呢?

嘿,这是Apache对你耍的一个鬼鬼祟祟的处理命令把戏。事实证明,将
Rewrite
命令放在文件顶部并不意味着它实际上是首先执行的。取而代之的是先运行
mod\u rewrite
,然后运行
mod\u alias
(它负责处理您的
rewrite

根据
mod_rewrite
,这将导致以下转换:

newsletter --> index.php?/newsletter
mod\u rewrite
愉快地将查询字符串设置为
?/newsletter
,但由于没有指定
PT
标志,因此不会将重写的URL
index.php
传递到
mod\u别名
。因此,
mod_alias
仍会看到
/newsletter
路径,将其重定向到
http://sub.domain.com/newsletters/may2010
,并在末尾附加(现在已更改)查询字符串
?/newsletter
,以确定交易。有趣的东西,对吧

无论如何,这个场景的一个快速修复方法是忽略对
时事通讯的请求:

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !newsletter$
RewriteRule ^(.*)$ index.php?/$1 [L]