2013-05-20 148 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在左側的側邊欄。

現在選擇使用服務器網址重寫

清除緩存。

完成