需要通过 mod_rewrite 访问 www - 需要附加条件吗?
要将 example.com 重写为 www.example.com,我被告知要在根 .htaccess 文件中使用以下规则:
# Require the www
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$
RewriteCond %{REQUEST_URI} !^/favicon\.ico$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
您能否解释一下这里的前五行有什么问题?他们真的需要/推荐吗? TIA
To rewrite example.com to www.example.com I was told to use the following rules within my root .htaccess file:
# Require the www
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$
RewriteCond %{REQUEST_URI} !^/favicon\.ico$
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Could you please explain what's the matter with the first five lines here? Are they really needed/recommended? TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.htaccess 技巧 本文将帮助您了解有关 htaccess 的所有技巧。稍后你自己决定是否需要前五行
希望有帮助
.htaccess tricks This article will help you to understand all the tricks about htaccess . Later yourself decide whether you need first five lines
Hope its helpful