URL重写,删除的.html [英] URL rewrite, remove .html

查看:438
本文介绍了URL重写,删除的.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你们知道这个...我们有一个网站,不幸的是所有的URL都将.html后缀,其Magento的安装,Magento的让你改变这种CMS上,但是,遗憾的是这一切的网址以.html后缀在谷歌一个好的排名。我们需要重定向到非。html的。

I know you guys know this one...we have a website, unfortunately all the URL's have the .html suffix, its a magento installation, magento allows you to change this on the cms, but again, unfortunately all this urls with .html suffix have a good ranking in Google. We need to redirect to non ".html" .

因此​​,考虑下面的情况,我们从头开始重建这个网站,所以我们有相同的URL在新网站上,但没有将.html后缀。

So, consider the following scenario, we are rebuilding this site from scratch, so we have the same urls on the new site but without the .html suffix.

现在是:www.mysite.de/cool-shoes.html

Now is: www.mysite.de/cool-shoes.html

将是:www.mysite.de/cool-shoes

will be: www.mysite.de/cool-shoes

所以www.mysite.de/cool-shoes.html将不再存在,我一直在试图与没有运气。htaccess的重定向。

So www.mysite.de/cool-shoes.html will not exist anymore, and I've been trying a redirect with the .htaccess with no luck.

我试过至今:

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

但它似乎并没有工作...任何想法?

but it doesn't seem to work...any ideas?

推荐答案

好了,所以,经过一番研究,并没有一个重写规则来实现这一目标,中code以下行的工作:

Ok so, after some research, and failing to achieve this with a rewrite rule, the following line of code worked:

redirectMatch 301 ^(.*)\.html $1

这是非常有用的,以消除任何URL扩展,避免无效链接,希望可以帮助别人的未来......

This is quite usefull to remove any url extension and avoid broken links, hopefully helps someone in the future...

干杯!

这篇关于URL重写,删除的.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆