magento - 为所有链接更改 URL

magento - change URL for all links

适用于

http://localhost.magento-store.com/index.php/fashion.html

但我需要它

http://localhost.magento-store.com/fashion.html

还能做什么?

服务器是否正在应用.htaccess文件?您可以通过在 .htaccess 文件中引入语法错误并查看您的服务器 returns 是否为 500 Internal Server Error 来对此进行测试。如果您没有收到错误,则说明您的 .htaccess 文件未被应用。这通常是由于服务器配置中的 AllowOverride 指令所致。尝试为您的 DocumentRoot 目录添加 AllowOverride All。请记住,这必须在服务器配置中完成,所以不要将其放在 .htaccess.

话虽如此,删除 RewriteBase 指令(或将其设置为 / 而不是 /magento-store.com/),并从 [=22= 中删除 /magento-store.com/ ] 指令。如果 http://localhost.magento-store.com/index.php/ 工作正常,那么您的 DocumentRoot 必须与 index.php 文件位于同一目录,因此您不想为 index.php 文件指定目录。

作为参考,这里是 Magento 示例 .htaccess 文件的精简版本:

<IfModule mod_rewrite.c>

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

    Options +FollowSymLinks
    RewriteEngine on

############################################
## rewrite API2 calls to api.php (by now it is REST only)

    RewriteRule ^api/rest api.php?type=rest [QSA,L]

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

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

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## 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>

请检查您的apache服务器rewrite_module是否启用。