我想用.htaccess文件的.htaccess自定义参数重定向
旧的URL重定向以下链接:localhost/info.php?butter_cake-cid111.html
要
新的URL:localhost/butter_cake/cid/111.html
在此先感谢。
我想用.htaccess文件的.htaccess自定义参数重定向
旧的URL重定向以下链接:localhost/info.php?butter_cake-cid111.html
要
新的URL:localhost/butter_cake/cid/111.html
在此先感谢。
您可以在DOCUMENT_ROOT/.htaccess
文件中使用这样的规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^([^-]+)-([a-z]+)(\d+\.html)$ [NC]
RewriteRule ^info\.php$ /%1/%2/%3? [L,NC,R=302]
RewriteCond
是匹配和捕获所有要在目标URL后使用的值。 ?
最后会剥离掉以前的查询字符串。
是否只有单个URL重定向或您有更多?如果是,则提供示例。 – anubhava
1000多旧的URL:本地主机/ info.php的butter_milk-cid112.html 要 新的URL:本地主机/ butter_milk/CID/112.html,还有更多像这样的 – Ajinkya