链接在谷歌搜索结果中不重定向到预期的页面按的.htaccess [英] Link in Google search results is not redirected to expected page as per .htaccess
问题描述
我原来问了一个问题的.htaccess <一href="http://stackoverflow.com/questions/25646268/htaccess-redirect-only-working-for-part-of-the-url/25646424#25646424">here并得到了一些真棒的帮助,开展工作的一种享受。基本上,我试图重定向从旧的网站页面到一个新的网站,并设法使大多数事情的工作。然而,有一对夫妇在谷歌的搜索结果链接未重定向正确的,我相信这是因为他们都WWW和新的网站重定向到非www。例如,像这样在搜索引擎结果中的链接:
I originally asked a .htaccess question here and got some awesome help, which worked a treat. Basically, I'm trying to redirect pages from an old site to a new site, and have managed to make most things work. However, there's a couple of links in Google's search results that aren't redirecting properly, and I believe this is because they're all www and the new site redirects to non-www. For example, a link like this in the search engine results:
www.example.com/Expertise/ProductTesting
www.example.com/Expertise/ProductTesting
应该去:
example.com/services/product-testing
example.com/services/product-testing
不过,而不是去:
example.com/services/ProductTesting
example.com/services/ProductTesting
所以由于某些原因URL的最后部分是不变化的。下面是这条线看起来在我的.htaccess:
So for some reason the last part of the URL isn't changing. Here's how that line looks in my .htaccess:
RedirectMatch 301 ^/Expertise/ProductTesting/?$ /services/product-testing/
如果我手动输入在地址并删除了www,它重定向所应当。
If I type the address in manually and drop the www, it redirects as it should.
在此先感谢!
推荐答案
以你的previous问题纳入考虑,你必须把你的新规则的之前这是匹配的一切的一种: RedirectMatch 301 ^ /专业/(.*)$ /服务/ $ 1
。
Taking your previous question into consideration, you must put your new rule before the one that is matching everything: RedirectMatch 301 ^/Expertise/(.*)$ /services/$1
.
此外,你也许已经再次开始前清除浏览器的缓存(或尝试用其他浏览器)。
Also, you'll maybe have to clear your browser's cache before trying again (or try it with another browser).
您的规则应该是这样的。
Your rules should look like this
RedirectMatch 301 ^/Expertise/QuantitativeResearch/?$ /services/quantitative-research/
RedirectMatch 301 ^/Expertise/ProductTesting/?$ /services/product-testing/
RedirectMatch 301 ^/Expertise/(.*)$ /services/$1
这篇关于链接在谷歌搜索结果中不重定向到预期的页面按的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!