这可能是因为mod_dir在内部处理请求。当你访问http://m.domain.com/shop-name然后它被重写为http://domain.com/ipad/shop-name时,mod_dir 302将浏览器重定向到http://domain.com/ipad/shop-name/。
您可以尝试处理RewriteRule中的尾部斜线。可能是一个这样做的更清洁的方式,而是沿着线的东西:
RewriteCond %{HTTP_HOST} ^m\.domain\.com?$
# Has trailing slash in request, don't need to append one in the RewriteRule
RewriteCond %{THE_REQUEST} ./\ HTTP/1\.[01]$
RewriteRule^http://domain.com/ipad%{REQUEST_URI} [L,P]
RewriteCond %{HTTP_HOST} ^m\.domain\.com?$
# Missing trailing slash in request
RewriteCond %{THE_REQUEST} [^/]\ HTTP/1\.[01]$
# Request doesn't end with one of these extensions, 301 redirect to include trailing slash
RewriteCond %{REQUEST_FILENAME} !\.(php|html?|jpg|gif)$
RewriteRule . http://m.domain.com%{REQUEST_URI}/ [R=301]
编辑:编辑解决301重定向缺少结尾的斜线
是“店铺名”的目录?你有权访问中央Apache配置文件(例如httpd.conf)或这些主机的'VirtualHost'部分吗? – JMM
这只是另一个RewriteRule。真正的路径是index.php?shop_name =无论它重定向到/ shop-name/ – Drew