我有一个多语言网站,我的第二语言转到子目录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>
请有人帮我这个吗?
答案 0 :(得分:0)
您需要关闭目录斜杠,然后使用重写规则添加尾部斜杠:
<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>