【发布时间】:2012-05-01 23:14:31
【问题描述】:
我们有一个网站,不幸的是所有的 URL 都有 .html 后缀,它是一个 Magento 安装,Magento 允许你在 CMS 上更改它,但不幸的是,所有这些带有 .html 后缀的 URL 都有一个很好的排名在谷歌。我们需要重定向到非.html。
因此,考虑以下场景,我们正在从头开始重建此站点,因此我们在新站点上具有相同的 url,但没有 .html 后缀。
- 现在是:
www.example.de/cool-shoes.html - 将是:
www.example.de/cool-shoes
所以www.example.de/cool-shoes.html 将不再存在,我一直在尝试使用 .htaccess 进行重定向,但没有成功。
到目前为止我已经尝试过:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule (.*)index\.html$ /$1 [R=301,L]
和:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
但它似乎不起作用......有什么想法吗?
【问题讨论】:
标签: apache .htaccess magento url-rewriting