.htaccess redirect example.com/magento/index.php到example.com/?

时间:2014-08-23 08:28:57

标签: .htaccess magento mod-rewrite subdirectory

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

我在根目录中有.htaccess个文件,' example.com'如下:

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]

.htaccess的标准Magento example.com/magento中,我已经取消注释了RewriteBase指令,如下所示:

RewriteBase /magento/

但是当我输入example.com时,浏览器会显示example.com/magento

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

留下RewriteBase评论

# 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>