我在我的共享主机服务器上安装了Magento。我已经在magento管理面板中做了所有必要的更改。所有的url都能正常工作。但唯一的问题是,我可以使用以下命令访问商店中的产品:
http://mydomain.com/category/product.html和http://mydomain.com/index.php/category/product.html
所以我想知道怎么才能摆脱index.php我想将包含index.php的url重定向到没有index.php的url
在这里发帖之前,我检查了magento论坛,也在stackoverflow上搜索,但没有找到成功。
发布于 2013-03-18 21:37:23
您可以捕获index.php之后的部分,并使用以下命令重定向客户端
RewriteEngine on
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]这会将所有以index.php/开头的请求重定向到不带index.php的URL。此外,index.php和index.php/被重定向到主页。
更新
要排除管理区域,必须在第一个规则之前插入额外的RewriteCond
RewriteCond %{REQUEST_URI} !/admin/所有这些都会给出
RewriteEngine on
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]发布于 2013-11-16 05:48:12
如果你想从你网站上的所有链接中删除index.php,这个解决方案对我来说是最好的:
RedirectMatch 301 /index.php/(.*) http://www.yourdomain.com/$1发布于 2018-05-15 19:14:43
使用此选项,您可以转义管理URL,并将301 index.php重定向到没有index.php url的位置
RedirectMatch 301 /index.php/((?!admin).*)$1 http://www.example.com/$1https://stackoverflow.com/questions/15476019
复制相似问题