我试图将seo友好的urls重定向到映射到我的主域的子域,这样子域就不会真正包含任何内容。只是化妆品而已。
RewriteEngine on
RewriteBase /
ErrorDocument 404 /notfound.php
RewriteRule ^$ index.php [L]
RewriteRule ^videos/(.*)-([0-9]+).html /videos/r/$1/ [R=301,L]
RewriteRule ^watch/([^/\.]+)/([^/\.]+).html$ /videos/$2-$1.html [R=301,L]
RewriteRule ^video/([^/\.]+)-([0-9]+).html$ watch.php?id=$2 [L]
RewriteRule ^video/(.*)/([^/\.]+)-([0-9]+).html$ watch.php?id=$3 [L]这会产生domain.com/video/seofriendyurl.html,我希望它重定向到subdomain.domain.com/video/seofriendlyurl.html.。只是化妆品而已。因此,如果我转到domain.com/video/seofriendyurl.html,我希望被重定向到subdomain.domain.com/video/seofriendlyurl.html。
发布于 2011-08-13 20:24:51
当使用[R=301]时,建议使用FQDN。
来自apache2文档
使用http://thishost[:thisport]/ (使新URL成为URI)进行前缀替换以强制外部重定向。
所以你的RewriteRules
RewriteRule ^$ index.php [L]
RewriteRule ^videos/(.*)-([0-9]+).html http://subdomain.domain.com/videos/r/$1/ [R=301,L]
RewriteRule ^watch/([^/\.]+)/([^/\.]+).html$ http://subdomain.domain.com/videos/$2-$1.html [R=301,L]
RewriteRule ^video/([^/\.]+)-([0-9]+).html$ watch.php?id=$2 [L]
RewriteRule ^video/(.*)/([^/\.]+)-([0-9]+).html$ watch.php?id=$3 [L]https://stackoverflow.com/questions/7052992
复制相似问题