我正在尝试将我网站上的一个目录重定向到 https。该目录根本不是真正的目录,因为站点是动态的。我使用 ExpressionEngine 作为 CMS。
我的 .htaccess 文件中已经有几行来删除 index.php ExpressionEngine 添加到它的所有 url。
这是我所拥有的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://mysite.com/store/$1 [R,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
当我访问时,http://mysite.com/store/ , 它返回 https://mysite.com/store/store/ .
我认为可能与以下几点有关:
RewriteRule ^(.*)$ /index.php?/$1 [L]
上面的行在 index.php 之后有一个问号,因为我遇到了“无输入文件”错误,这是推荐的修复方法。
有什么想法吗?
最佳答案
这里是这一行:
RewriteCond %{REQUEST_URI} store
应该在“store”前面有一个!
:
RewriteCond %{REQUEST_URI} !store
因为如果 URI 已经是 /store
,您不希望它重定向。
关于.htaccess - 尝试将目录重定向到 https 但在返回时得到双 URL 段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13639770/