.htaccess将example.com/magento/index.php重定向到example.com/?

.htaccess将example.com/magento/index.php重定向到example.com/?,.htaccess,magento,mod-rewrite,subdirectory,.htaccess,Magento,Mod Rewrite,Subdirectory,我在一个子目录中安装了Magento,Magento的路径是example.com/Magento 我在根目录“example.com”中有一个.htaccess文件,如下所示: Options +FollowSymLinks RewriteEngine On RewriteCond %{http_host} ^example.com [NC] RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L] RewriteCond

我在一个子目录中安装了Magento,Magento的路径是
example.com/Magento

我在根目录“example.com”中有一个
.htaccess
文件,如下所示:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST}   ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/magento(/.*)?$ [NC]
RewriteRule ^(.*)$         /magento/$1    [QSA,L]
RewriteBase /magento/
example.com/Magento
中的标准Magento
.htaccess
中,我取消了RewriteBase指令的注释,如下所示:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^magento/(.+)$ http://www.example.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST}   ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/magento(/.*)?$ [NC]
RewriteRule ^(.*)$         /magento/$1    [QSA,L]
RewriteBase /magento/
但是当我键入
example.com
时,浏览器会显示
example.com/magento


我怎样才能解决这个问题?

请留下评论

# RewriteBase /magento/
请在/.htaccess中尝试以下操作:

RewriteEngine on
RewriteRule ^(.*)$ /magento/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]
并将其添加到您的magento/.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [L]
</IfModule>

重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则[L]

我认为应该是
RewriteBase/
,因为这个.htaccess在你的站点的根目录中。除此之外,您的第一个条件/规则可能不匹配,因此不会重定向用户。@Sumurai8,也许您是对的。但我对.htaccess配置一无所知。如果你能在这个问题上帮助我,我会很高兴的。