Currently Viewing Posts Tagged 301

Fix some Crawl errors of my blog

I found some errors in Google Search Console —¬† Crawl Error. More than 400 errors of Not-Found.

After checking the details of these errors, I am noticed that they are the dead links which were brought after I converted this blog from MovableType to WordPress.

Some links are changed and I forgot to implement the redirection.

OK. Now I add some rules in .htaccess file to make these dead link to redirect to the correct URLs.

301_htaccess_redirect

Here is some examples.

Monthly archives:

Old url is https://www.yinfor.com/archives/2012/09/

New url is https://www.yinfor.com/2012/09/

So I added following rule into .htaccess file in root.

# Redirect monthly archives
RewriteRule ^archives/([0-9\/]*)/ /$1/ [R=301,L]

Tag page:

Old tag page is https://www.yinfor.com/mtcgi/mt-search.cgi?IncludeBlugs=4,1&tag=beta&limit=20

New tag page is https://www.yinfor.com/tag/beta/

I add following rule into .htaccess

RewriteCond %{QUERY_STRING} ^IncludeBlogs=([0-9,]*)&tag=(.*)&limit=20$
RewriteRule ^(.*)$ https://www.yinfor.com/tag/%2? [L,R=301]

Another type of tag page:

Old tag page is https://www.yinfor.com/mtcgi/mt-search.cgi?tag=Gogle&blog_id=5

New tag page is https://www.yinfor.com/tag/Google/

Add following into .htaccess file.

RewriteCond %{QUERY_STRING} ^tag=(.*)&blog_id=([0-9])$
RewriteRule ^(.*)$ https://www.yinfor.com/tag/%1? [L,R=301]

Nginx Redirect HTTP to HTTPS and non-WWW to WWW

Here is my solution to do the redirection.

Say, I have a web site. I host it with SSL.

I want all these three type of host go to the same Unique Internet Address.

From:

  • http://example.com/
  • http://www.example.com/
  • https://example.com/

To:

  • https://www.example.com/

There are some requirement:

  • Nginx v1.8
  • SSL Certificate is issued for both¬† example.com and www.example.com

Continue reading “Nginx Redirect HTTP to HTTPS and non-WWW to WWW”

  • Archives