redirecting with htaccess while avoiding search engine penalty

筅森魡賤 提交于 2019-12-11 10:47:43

问题


I have a website that has been up for about 2 years now, it gained some search engine reputation over the time, and now I'm interested in using htaccess on it, to rename things such as:

/index.php?act=Login to simply /Login

Now the problem is, that search engines will see both urls, and the login page is far from being the only url I will rename. Which pretty much means that my entire website will have double the urls it has now, What can I do to prevent it from causing damage to the SEO?

Is there some line of htaccess code I could use to redirect the old pages to the new ones as well? (I'm not even sure if that'll solve the SEO issue)

Thanks in advance


回答1:


Bottom line is to use R=301 (moved permanently) to inform search engines about your new URLs. For ex have your .htaccess code like this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# external redirect using R=301 to /login from /index.php?act=Login
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(index\.php/?|)\?act=login(&|\s) [NC]
RewriteRule ^ /login? [R=301,L]

# internal forward from /login to /index.php?act=Login
RewriteRule ^login/?$ index.php?act=login [L,QSA,NC]

With R=301 directive search engines will eventually start caching your new URI scheme instead of the old ones.



来源:https://stackoverflow.com/questions/12244657/redirecting-with-htaccess-while-avoiding-search-engine-penalty

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