2013-05-20 164 views
2

我最近设置了一个magento商店,URL是mydomain.com/index.php/admin或mydomain.com/index.php/about-us。我想删除的index.php,我用Google搜索这个码应该如何,我找到了工作方法,但它并不:在.htaccess中删除Magento URL中的Index.php

<IfModule mod_rewrite.c> 

############################################ 
## enable rewrites 

    Options +FollowSymLinks 
    RewriteEngine on 

############################################ 
## you can put here your magento root folder 
## path relative to web root 

    RewriteBase/

############################################ 
## workaround for HTTP authorization 
## in CGI environment 

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

############################################ 
## always send 404 on missing files in these folders 

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ 

############################################ 
## never rewrite for existing files, directories and links 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-l 

############################################ 
## rewrite everything else to index.php 

    RewriteRule .* index.php [L] 

</IfModule> 

感谢。

回答

1

你有什么要确保第一,是在Apache的,(如果这是你使用的是什么),使Mod Rewrites ......然后,您可以添加以下到您的.htaccess文件。

要启用Mod Rewrites

sudo a2enmod 

从SSH命令行(或跟你的主机)

的.htaccess:

RewriteEngine on 
RewriteRule .* index.php [L] 
+0

所以你说我上面发布的代码已经取消了index.php网址?我有mod_rewrite启用。 – ratman2050

+0

这就是我所说的。是的 - >你也使用'RewriteEngine on'吗?这是必需的。 – Zak

+0

请参阅编辑答案。 – ratman2050

1

你真的应该使用第二种方法,让Magento的强制重写规则。它是最干净的方式。它会做到这一点,在所有情况下从url中删除index.php。

+0

然而这不是为我工作吗? – ratman2050

+0

请参阅编辑答案。 – ratman2050

+0

尝试备份该文件(php.ini正确?),然后删除所有重写规则。然后尝试从Magentos后端启用它,或将php.ini替换为原始的php.ini文件以进行默认的magento安装。 – david

1

看起来你已经给你的Magento根文件夹的错误的相对路径:

## you can put here your magento root folder 
## path relative to web root 

RewriteBase/
0

转到Magento的后端

导航到系统>配置然后Web在左侧的侧边栏。

现在选择使用服务器网址重写

清除缓存。

完成