我的.htaccess
文件如下所示:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com [NC]
RewriteRule ^(.*)$ http://mywebsite.com/$1 [L,R=301]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule ^resources/([^/\.]+)/?$ page.php?theme=resources&pg=$1 [L]
RewriteRule ^resources/([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=resources&pg=resources&catname=$1&cat=$2 [L]
RewriteRule ^resources/([^/\.]+)/?/([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=resources&catname=$1&cat=$2&pg=$3 [L]
RewriteRule ^albums/([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=albums&pg=albums&albumname=$1&album=$2 [L]
RewriteRule ^albums/([^/\.]+)/?$ page.php?theme=albums&pg=albums [L]
RewriteRule ^leaving-the-site/([^/\.]+)/?$ page.php?theme=leaving-the-site&pg=leaving-the-site&q=$1 [L]
RewriteRule ^([^/\.]+)/?/([^/\.]+)/?$ page.php?theme=$1&pg=$2 [L]
RewriteRule ^([^/\.]+)/?$ page.php?theme=$1&pg=$1 [L]
一切似乎都很好,但是当我们重新启动网站时,我们需要实施大约110 301次重定向。它们的格式类似于以下内容,并在上述重写规则之后添加:
RewriteRule ^about/about-the-site$ https://www.mywebsite.com/about-us? [L,NC,R=301]
我的问题是,只要我上传了所有301s的htaccess文件,它就会开始放慢网站的速度,到大约10分钟内有60秒的加载时间,然后开始超时。
我删除301重定向,然后恢复。根据我的研究,301重定向可能会降低服务器的速度,但不会显着降低,至少不会少于1000行。
我应该采取哪些不同的做法?
答案 0 :(得分:0)
这是HTTPS / SSL& www到非www重写|专门为WordPress重定向htaccess代码,但您可以为您的特定网站修改/自定义它。我还在看你的其他代码......
编辑:好的,我查看了您的其他代码,它过于复杂,代码中使用问号可能不正确。我建议你做的是使用RewriteCond查询字符串匹配代码而不是你现在尝试使用的方向/代码。请参阅此主题,例如RewriteCond查询字符串匹配htaccess代码示例:Replace "index.php?option=com_k2&view=item&id=" using .htaccess and Regex
# WP REWRITE LOOP START
# Rewrite|Redirect http to https|SSL & www to non-www
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80
RewriteCond %{HTTP_HOST} ^www\.domainname\.com$ [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^index\.php$ - [L]
# All lines of Rewrite|Redirect code would go here
# if file or directory does not exist then Rewrite to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# WP REWRITE LOOP END