我需要将旧网址重定向到位于 http://www.domain.com/mobile/
的移动版网站中的 seoed 网址,并且有自己的 .htaccess
文件具有以下重写规则:
RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3
我如何 301 将旧网址重定向到新网址?
最佳答案
这样说:
RewriteEngine On
RewriteBase /mobile/
RewriteCond %{THE_REQUEST} /category\.php\?cat=([^\s&]+)\s [NC]
RewriteRule ^ browse-%1-videos.html? [R=302,L,NE]
RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1 [L,QSA,NC]
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3 [L,QSA,NC]
关于regex - 301 将旧网址重定向到移动网站中的新网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35301181/