重定向没有get-params

时间:2015-09-19 07:31:38

标签: regex apache .htaccess

我需要从url-string中删除get params。来自.htaccess的代码:

RewriteEngine On


        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
        RewriteRule ^index\.php$ http://formaspravki.com? [R=301,L]

        RewriteCond %{HTTP_HOST} ^www.formaspravki\.com
        RewriteRule ^(.*)$ http://formaspravki.com/$1? [R=permanent,L]

        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^www.forma-spravki\.com
        RewriteRule ^(.*)$ http://formaspravki.com/$1? [R=permanent,L]

        RewriteEngine On
        RewriteCond %{HTTP_HOST} ^forma-spravki\.com
        RewriteRule ^(.*)$ http://formaspravki.com/$1? [R=permanent,L]

        DefaultLanguage ru
        AddDefaultCharset windows-1251
        #php_value default_charset "cp1251"

        # Редиректы
        RewriteRule ^page/([0-9]+)(/?)$ index.php?cstart=$1? [L]
    RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)/page/([0-9]+)(/?)+$index.php?do=cat&category=$1&cstart=$2[L]
        RewriteRule ^([^.]+)/?$ index.php?do=cat&category=$1 [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^([^.]+)/rss.xml$ engine/rss.php?do=cat&category=$1 [L]
        RewriteRule ^page,([0-9]+),([^\/]+).html$ index.php?do=static&page=$2&news_page=$1 [L]
        RewriteRule ^print:([^\/]+).html$ engine/print.php?do=static&page=$1 [L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^([^\/]+).html$ index.php?do=static&page=$1 [L]

        Redirect 301 /spravka_rabotodatelyu_o_beremennosti.html http://formaspravki.com/spravka-o-beremennosti.html
        Redirect 301 /spravka_o_beremennosti_obrazec.html http://formaspravki.com/spravka-o-beremennosti.html

Afer重定向,在url字符串中出现参数?do = static& page ='page name'。 当我添加下一个代码参数disapper,但浏览器中的内容没有加载:

RewriteCond %{QUERY_STRING} !="^do=static$"
RewriteRule ^(.*)$ http://example.com/$1? [L]

添加'?'指令或删除查询字符串没有帮助。

1 个答案:

答案 0 :(得分:0)

尝试将[QSD] flag附加到您的网址,例如:

RewriteRule ^index\.php$ http://example.com [R=301,L,QSD]