redirecting with htaccess while avoiding search en

2019-08-14 06:51发布

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条回答
一夜七次
2楼-- · 2019-08-14 07:47

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.

查看更多
登录 后发表回答