将index.php重定向到.htaccess中的root

Spi*_*gon 1 .htaccess mod-rewrite url-rewriting magento magento-1.7

我在我的共享托管服务器上安装了Magento.我在magento管理面板中进行了所有必要的更改.所有的网址都很好.但唯一的问题是我可以使用以下方式访问商店中的产品:

http://mydomain.com/category/product.html以及http://mydomain.com/index.php/category/product.html

所以我想知道如何摆脱index.php.我想将由index.php组成的url重定向到没有index.php的url

在发布之前我检查了magento论坛,并在stackoverflow上搜索但没有成功.

Ola*_*che 6

您可以捕获部件index.php并重定向客户端

RewriteEngine on
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
Run Code Online (Sandbox Code Playgroud)

这会将所有index.php/以URL 开头的请求重定向到URL index.php.此外index.php,index.php/并重定向到主页.

更新:

要排除管理区域,必须RewriteCond在第一个规则之前插入其他区域

RewriteCond %{REQUEST_URI} !/admin/
Run Code Online (Sandbox Code Playgroud)

一共给出

RewriteEngine on
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
Run Code Online (Sandbox Code Playgroud)