我需要使用.htaccess
“重写”这些网址...需要删除第一个和最后一个网址,所以
/articles/marketing-stuff/seo-management/1418/
应该
成为/marketing-stuff/seo-management/
/articles/command-line/linux-post/2131/
需要
成为/command-line/linux-post/
我有这些重写规则,但它们无法正常工作:
RewriteCond %{REQUEST_URI} /articles/marketing-stuff/(.*)/(\d+)/?
RewriteRule ^/articles/marketing-stuff/(.*)/(\d+)/?$ /marketing-stuff/$1/
RewriteCond %{REQUEST_URI} /articles/command-line/(.*)/(\d+)/?
RewriteRule ^/articles/command-line/(.*)/(\d+)/?$ /command-line/$1/
我错过了什么?
答案 0 :(得分:1)
您可以使用:
RewriteEngine on
RewriteRule ^articles/(marketing-stuff|command-line)/(.*)/(\d+)/?$ /$1/$2/ [NC,L]