這可能是因爲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