htaccess redirect 301

我与影子孤独终老i 提交于 2019-12-24 06:26:55

问题


Google says that the content is duplicated
www.example.com/pagedcontent/page3 /
www.example.com/pagedcontent/page3

I redirected using redirect 301 for each page, but as they are already more than 150 pages would like to use a single instruction in the htaccess.

How to do? Please I want to redirect to www.example.com/pagedcontent/page3 (without / at end)


回答1:


Like this:

RewriteEngine On
RewriteRule ^pagedcontent/([A-Za-z0-9]*)/$ /pagedcontent/$1 [NC]

That will remove the trailing slash for any page under pagedcontent.

You can also use the canonical meta tag, which is a way of specifying the original copy of the page. Put a meta tag in the head of your page like so:

Google will know that all other duplicates of this page are copies of it.



来源:https://stackoverflow.com/questions/2041525/htaccess-redirect-301

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!