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-> 网络服务器重写:是
在前端使用安全 URLs : yes
还能做什么?
服务器是否正在应用.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是否启用。
适用于
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-> 网络服务器重写:是 在前端使用安全 URLs : yes
还能做什么?
服务器是否正在应用.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是否启用。