重写网址类别ID

时间:2013-10-12 14:44:18

标签: .htaccess categories

我想删除子类别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
你能帮帮我吗? 此致

1 个答案:

答案 0 :(得分:0)

启用mod_rewrite.htaccesshttpd.conf,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^(category)/[0-9]+-([^/]+/[^.]+\.html)$ /$1/$2 [L,NC,R=302]