【问题标题】:expressionengine Remove question mark from url after search submit搜索提交后从 url 中删除问号
【发布时间】:2015-04-24 19:37:17
【问题描述】:

我有一个多语言网站,我的第二语言位于子目录mysite.com/en/。一切都很好,但搜索功能。当我提交搜索时,它会在子目录之后打印一个问号,如下所示:

mysite.com/en/?/noresult/6bc629a9319d90a1e9703eaf2c00f7cd/  

因此,我的网站重定向到主页。我搜索并尝试了许多.htaccess 代码,但没有奏效。不带问号的网址可以正常使用。

这是我的.htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /en/

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)/index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)$ /en/index.php?/$1 [L]
    RewriteRule ^(.*)$ /en/index.php?/$1 [L,QSA]
</IfModule>

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: .htaccess expressionengine


    【解决方案1】:

    您需要保持目录斜线关闭,然后使用重写规则添加尾部斜线:

    <IfModule mod_rewrite.c>
        DirectorySlash Off  
        RewriteEngine On
        RewriteBase /en/
    
        # Removes index.php from ExpressionEngine URLs
        RewriteCond %{REQUEST_METHOD} !POST
        RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
        RewriteCond %{REQUEST_URI} !/system/.* [NC]
        RewriteRule (.*?)/index\.php/*(.*) $1$2 [R=301,NE,L]
    
        # add a trailing slash to directories
        RewriteCond %{REQUEST_METHOD} !POST
        RewriteCond %{DOCUMENT_ROOT}/en/$1 -d
        RewriteRule ^(.*?[^/])$ /en%{REQUEST_URI}/ [L,NE,R=302]
    
        # Directs all EE web requests through the site index file
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    </IfModule>
    

    【讨论】:

    • 我检查过,同样的问题
    • 很遗憾,用 同样的问题 发表评论将无济于事。你在做一个表格帖子吗?打开 Chrome 开发工具,然后搜索并查看是否有 301 重定向或您的表单操作导致此问题。
    • 是的,它正在向“mysite.com/en/”发送表单,GET url 是“mysite.com/en/?/noresult/6bc629a9319d90a1e9703eaf2c00f7cd/”
    猜你喜欢
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 2015-07-28
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    相关资源
    最近更新 更多