Sunday, March 18, 2012

Magento去掉url中的index.php及问题解决

环境apache  magento1.4.0.1
apache开启mod_rewrite 和 mod_alias 后建立虚拟目录安装magento
完成之后默认的Use Web Server Rewrites 设置项为 yes
这个时候进入子页面 往往会出现类似 The requested URL  /...../....  was not found on this server 的错误
如果在其中加入 index.php就可以正常访问了
eg:127.0.0.1/magento/customer/account/login/  无法正常访问
修改为: 127.0.0.1/magento/index.php/customer/account/login/
后就可以正常访问了
这个时候我们可以将  Use Web Server Rewrites 设置为 No
不过这就达不到去掉url中的index.php的效果了
所以我们需要修改  .htaccess   文件来实现
Apache的一些简要配置如下
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

Alias /mag1401 "D:\web\mag1401"
<Directory "D:\web\mag1401">
AllowOverride All
Allow from all
</Directory>

根据上面的设置修改.htaccess 文件
############################################
## you can put here your magento root folder
## path relative to web root

RewriteBase /mag1401/
############################################
注意RewriteBase 的路径与Alias是对应的
这样开启Use Web Server Rewrites后就可以去掉URL中index.php正常访问了

1 comment:

  1. Dear, again in the valentine's day.I don't know how many of you have me to your chocolate, but I see clearly...This year I can send--to reduce weight tea?
    http://www.mmomesos.com

    ReplyDelete