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文件包括

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /magento-store.com/
    RewriteRule ^index'.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /magento-store.com/index.php [L]
    </IfModule>
    
  • 数据库中的基本 URL http://localhost.magento-store.com/

  • 管理面板:SEO>网络服务器重写:是在前端使用安全网址:是

还要做什么?

服务器

是否正在应用.htaccess文件?您可以通过在.htaccess文件中引入语法错误并查看服务器是否返回500 Internal Server Error来测试这一点。如果未收到错误,则表示未应用.htaccess文件。这通常是由于服务器配置中的AllowOverride指令造成的。尝试为 DocumentRoot 目录添加AllowOverride All。请记住,这必须在服务器配置中完成,因此不要将其放在 .htaccess .

话虽如此,请删除 RewriteBase 指令(或将其设置为 / 而不是 /magento-store.com/ ),并从 RewriteRule 指令中删除/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