简体   繁体   English

如何执行301从非https www重定向页面。 html网页到WordPress网站,且没有https和www,URL中的关键字完全不同?

[英]How to do 301 redirects on pages from non https www. html pages to a WordPress site with https and no www AND totally different keywords in URLs?

I'm moving a 180 page html non https site over to WordPress and to https AND changing the keywords of the URLs in an .htaccess file 我要将一个180页的HTML非https站点移到WordPress和https上,并更改.htaccess文件中URL的关键字

AND some of the files are http: //www.site.com/keyword-abc.html 并且其中一些文件是http://www.site.com/keyword-abc.html

and some don't have the www, Ie, they're http: //site.com/keyword-abc.html 还有一些没有www的网站,例如http://site.com/keyword-abc.html

So I need to manually find some way to list both the html files http: //www.site.com/keyword-abc.html 因此,我需要手动找到一些方法来列出两个html文件:http://www.site.com/keyword-abc.html

And the

http: //site.com/keyword-abc.html http://site.com/keyword-abc.html

And redirect it not only to https but also change the URL after the domain name like 并将其不仅重定向到https,而且还会在域名后更改URL,例如

https: //site.com/new-keyword-that-ranks/ https://site.com/new-keyword-that-ranks/

I don't want to use a WordPress plugin to do it but .htaccess file in Apache. 我不想使用WordPress插件来执行此操作,而是使用Apache中的.htaccess文件。

How to I write the code for moving both the www and the non www insecure urls to https and totally different keywords in the htaccess file? 如何编写将www和非www不安全的URL都移动到htaccess文件中的https和完全不同的关键字的代码?

I know I will have to write a line of code or two for each URL I want to change. 我知道我要为每个要更改的URL写一两行代码。

Does it matter if I do the http: //www.site.com/keyword-abc.html first before the http: //site.com/keyword-abc.html in the redirect? 是否在重定向中先执行http://www.site.com/keyword-abc.html之前先执行http://www.site.com/keyword-abc.html?

If I put a space between each URL change to be able to see and trouble shoot it easier, will that affect the speed of the redirects or cause any problems? 如果我在每个URL更改之间放置一个空格以便能够轻松查看和排除故障,这会影响重定向的速度还是会导致任何问题?

I've gone over lots of tutorials for .htaccess and have never seen any of them that does both a www non secure to https redirect, AND an http:// no www to https redirect AND different keywords in the new URL. 我已经看过很多有关.htaccess的教​​程,但从未见过其中的任何一个都对www重定向到https重定向不安全,并且对http重定向没有http:// no www以及在新URL中使用不同的关键字。

I think the hard part is the different keywords after the domain name but I've already built the site with those URLs in it. 我认为最困难的部分是域名后的不同关键字,但是我已经用这些URL构建了网站。

This is for a .htaccess file for an Apache server. 这是针对Apache服务器的.htaccess文件。

Would this code work? 这段代码行得通吗?

301 Redirect 1 301重定向1

RewriteRule ^addintheworkplacearticles.html$ https://example.com/manage-adhd-at-work/ [R=301,L] RewriteRule ^ addintheworkplacearticles.html $ https://example.com/manage-adhd-at-work/ [R = 301,L]

301 Redirect 2 301重定向2

enter code here RewriteRule ^adhdmedicationart.html$ https://example.com/adhd-medication-articles/ [R=301,L] enter code here enter code here RewriteRule ^ adhdmedicationart.html $ https://example.com/adhd-medication-articles/ [R = 301,L] enter code here

301 Redirect 3 301重新导向3

enter code here RewriteRule ^adhdmedicationco.html$ https://example.com/adhd-medication-company-websites/ [R=301,L] enter code here enter code here RewriteRule ^ adhdmedicationco.html $ https://example.com/adhd-medication-company-websites/ [R = 301,L] enter code here

continue this on all the other individual page to page redirects, then paste this code after it 在所有其他单个页面上继续执行此操作以重定向到页面,然后在其后粘贴此代码

Redirect non-HTTP or non-www to HTTPS without www 将非HTTP或非www重定向到不带www的HTTPS

enter code here RewriteCond %{HTTPS} =off [OR] RewriteCond %{HTTP_HOST} !^(example.com)$? enter code here RewriteCond%{HTTPS} = off [OR] RewriteCond%{HTTP_HOST}!^(example.com)$? RewriteRule ^(.*)$ https://example.com/ $1 [R=301,L] enter code here RewriteRule ^(。*)$ https://example.com/ $ 1 [R = 301,L] enter code here

than after that code, put the WordPress htaccess code 而不是该代码之后,放上WordPress htaccess代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM