我想删除子类别ID并使用rewriteurl重定向到新网址。我有很多这样的网址
www.abc.com/category/(subcategoryid)-subcategory/(articleid)-article.html
实施例
www.abc.com/category/12-subcategoryA/1054-article.html
www.abc.com/category/23-subcategoryB/1072-another-article.html
VS
到
www.abc.com/category/subcategoryA/1054-article.html
www.abc.com/category/subcategoryB/1072-another-article.html
你能帮帮我吗?
此致
答案 0 :(得分:0)
启用mod_rewrite
和.htaccess
至httpd.conf
,然后将此代码放入DOCUMENT_ROOT/.htaccess
文件中:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(category)/[0-9]+-([^/]+/[^.]+\.html)$ /$1/$2 [L,NC,R=302]