有没有人知道RewriteRule会重定向一个非www。为了。版本,,但不知道TLD会是什么?,也就是.
http://example.com -> http://www.example.com
http://example.co.uk -> http://www.example.co.uk
http://example.fr -> http://www.example.fr
http://example.de/something.html -> http://www.example.de/something.html我宁愿有一个整洁的规则,而不是列出所有可能的TLD,但不知道如何做,我搜索,但找不到类似的东西。
有什么想法吗?
发布于 2015-02-18 07:12:36
其实很简单。
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]条件检查域名是否以www.开头,如果这是真的,这次重定向完整的www.请求。
https://stackoverflow.com/questions/28573932
复制相似问题