Reputation: 427
I have these URLs that need to be 'rewritten' using .htaccess
... The first and last segment need to be removed, so
/articles/marketing-stuff/seo-management/1418/
should
become /marketing-stuff/seo-management/
/articles/command-line/linux-post/2131/
needs to
become /command-line/linux-post/
I have these rewrite rules but they're not working:
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/
What am I missing?
Upvotes: 0
Views: 118
Reputation: 18671
You can use:
RewriteEngine on
RewriteRule ^articles/(marketing-stuff|command-line)/(.*)/(\d+)/?$ /$1/$2/ [NC,L]
Upvotes: 1