.htaccess规则显示重定向过多

时间:2018-08-03 12:44:44

标签: apache .htaccess mod-rewrite

我正在使用移动版本域,并使用.htaccess规则将其重定向,效果很好。

RewriteEngine On RewriteCond %{HTTP_USER_AGENT} (iphone|ipad|android|blackberry|windows\ phone) [NC] RewriteCond %{HTTP_HOST} ^www.example.com$ [NC] RewriteRule ^(.) https://m.example.com/$1 [L,R] RewriteCond %{HTTP_USER_AGENT} (iphone|ipad|android|blackberry|windows\ phone) [NC] RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.) https://m.example.com/$1 [L,R]

但是,我找不到规则来将www.example.com和example.com的所有相应页面重定向到https://www.example.com(所有不包含任何数值的url)。请参见以下示例:

example.com和www.example.com应该重定向到https://www.example.com example.com/abc/def和www.example.com/abc/def应该重定向到https://www.example.com/abc/def

example.com/133/hey和www.example.com/133/hey不应重定向到https://www.example.com/133/hey

我尝试了一些方法,但是打开页面时它显示了太多的重定向。

0 个答案:

没有答案