htaccess 将非 www 重定向到 www 而不会丢失脚本和查询
htaccess redirect non-www to www without losing script and query
我想从这里重定向:
http://example.com/admin/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
为此:
http://www.example.com/admin/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
我的 htaccess:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/%{THE_REQUEST} [R=301,L]
但它会将我重定向到此:
http://www.example.com/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
使用这个:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
我想从这里重定向:
http://example.com/admin/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
为此:
http://www.example.com/admin/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
我的 htaccess:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/%{THE_REQUEST} [R=301,L]
但它会将我重定向到此:
http://www.example.com/index.php?route=common/home&token=e687040d4b0f5f42a4eab8951a3b57b4
使用这个:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]