我.htaccess
文件看起来像这样:htaccess的&301个重定向造成服务器速度变慢
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条。
有什么我应该做的不同吗?
必须使用的.htaccess(你可以访问apache的conf文件)? –
如果您有权访问apache配置文件,您可以使用'RewriteMap'加快.htaccess加载时间 – anubhava
我对“RewriteMap”一无所知,因此我将开始研究它。我应该能够访问conf文件;我只是没有 – TH1981