Php htaccess重定向正在追加查询字符串

Php htaccess重定向正在追加查询字符串,php,apache,.htaccess,codeigniter,Php,Apache,.htaccess,Codeigniter,如果我转到rocketroffing.us/rocket,它会将我重定向到rocketroffing.us/rochester-minnesota屋顶承包商?/rocket。为什么它要附加那个查询字符串?我如何修复它 .htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #Removes access to the system folder by users. #Add

如果我转到rocketroffing.us/rocket,它会将我重定向到rocketroffing.us/rochester-minnesota屋顶承包商?/rocket。为什么它要附加那个查询字符串?我如何修复它

.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    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]

    # redirect from the old controller names to the new ones to try and help our SEO.
    #redirect 301 / http://rocketroofing.us/rochester-minnesota-roofing-contractor
    redirect 301 /rocket http://rocketroofing.us/rochester-minnesota-roofing-contractor
    redirect 301 /about http://rocketroofing.us/about-rochester-rocket-roofing
    redirect 301 /faq http://rocketroofing.us/frequently-asked-questions
    redirect 301 /contact http://rocketroofing.us/contact-minnesota-roofing-company

</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> 

您正在请求此处的行为:

RewriteRule ^(.*)$ index.php?/$1 [L]
$1
是对正则表达式中与
*
匹配的任何内容的反向引用

除非您这样定义自己的查询字符串,否则将使用该查询字符串:

redirect 301 /rocket http://rocketroofing.us/rochester-minnesota-roofing-contractor?
注意后面的问号。记录:

默认情况下,查询字符串在传递过程中保持不变。你可以, 但是,请在包含查询的替换字符串中创建URL 弦部分。只需在替换字符串中使用问号即可 指示应将以下文本重新注入 查询字符串。如果要删除现有查询字符串,请结束 仅带问号的替换字符串。新旧结合 查询字符串时,请使用[QSA]标志


在使用您的建议时,问号位于重定向的url中。有没有办法在重定向的url中不使用问号?@Catfish-您可以在配置文件中指定它,但它仍然不应该是重定向url的一部分。你认为这是为什么?你有任何能检测到它的代码吗?哦,所以我所需要做的就是从
重写规则中删除问号?哎呀,你为什么不这么说!我使用的htaccess文件发布在CI网站上,用于从url中删除index.php。不知道你对CI有多熟悉,但谢谢你的帮助!非常感谢。@鲶鱼-不客气。我认为您可能需要重定向URL中的其他参数,所以我认为解释整个管道更安全。
redirect 301 /rocket http://rocketroofing.us/rochester-minnesota-roofing-contractor?