我有一些需要用.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/我遗漏了什么?
发布于 2017-06-16 14:48:16
您可以使用:
RewriteEngine on
RewriteRule ^articles/(marketing-stuff|command-line)/(.*)/(\d+)/?$ /$1/$2/ [NC,L]https://stackoverflow.com/questions/44592030
复制相似问题