[英]Redirect old dynamic url to a new pattern using htaccess
A normal link of my site may look like this我网站的正常链接可能如下所示
mydomain.com/categorylist/8/Special_Single_Songs.html mydomain.com/categorylist/8/Special_Single_Songs.html
I'm planning to change the URL pattern to something like我打算将 URL 模式更改为类似
mydomain.com/categorylist/8-Special-Single-Songs.html mydomain.com/categorylist/8-Special-Single-Songs.html
How can I redirect the old URL pattern to the new one using .htaccess redirect rule?如何使用 .htaccess 重定向规则将旧的 URL 模式重定向到新的 URL 模式?
My .htaccess Rewrite rule look like this我的 .htaccess 重写规则如下所示
RewriteRule ^categorylist/([0-9]+)/([0-9a-z]+)/([0-9]+)/(.*)\.html$ /index.php?pid=$1&sort=$2&page=$3 [L]
Try this code试试这个代码
RewriteRule ^categorylist/([0-9]+)/([0-9a-z]+)/([0-9]+)/(.*).html$ /index.php?pid=$1&sort=$2&page=$3 [L]
RewriteRule ^categorylist/([0-9]+)\-([0-9a-z]+)/([0-9]+)/(.*).html$ /index.php?pid=$1&sort=$2&page=$3 [L]
try this & put it on top after RewriteEngine on试试这个并在 RewriteEngine 打开后把它放在上面
RewriteRule ^categorylist([^_]*)_([^_]*_.*).html$ $1-$2 [L,NE]
RewriteRule ^categorylist([^_]*)_([^_]*).html$ /$1-$2 [L,NE,R=301]
note : big number of underscores can be a problem注意:大量的下划线可能是一个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.