【发布时间】:2015-11-05 17:24:53
【问题描述】:
你能看看下面的代码,看看这是否是正确的方法吗?
为了重定向:
http://blog.exampledomain.com/2013/10/testpage.html
到
https: //exampledomain.com/blog/testpage/
我在 2 个 .htaccess 文件中放置了以下重写规则:
-
在
exampledomain.com的根目录下的.htaccess 文件中我已经放置了:RewriteCond %{HTTP_HOST} ^blog\.exampledomain\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www\.blog\.exampledomain\.com$ [NC] RewriteRule ^(.*)$ https://exampledomain.com/blog/$1 [R=301,L] -
在
exampledomain.com/blog的blog文件夹的.htaccess文件中我已经放置了:RewriteRule ^([0-9]{4})/([0-9]{2})/(.*)\.html https://exampledomain.com/blog/$3/ [R=301,L]
问题:
这是正确的做法吗?
这是否意味着在此设置中我们有 2 个重定向? (这可能对 SEO 不利)这些应该结合起来吗?怎么样?
【问题讨论】:
-
您的 子域
blog.是否指向与您的主域相同的文档根目录? -
是的,子域曾经是一个不再使用的 blogspot,并被子文件夹中的博客替换。但在当前设置中,子域博客。具有相同的根。
标签: regex apache .htaccess mod-rewrite redirect