301 redirect in htaccess

2019-09-17 16:37发布

I changed the URL of my articles so I need to be able to redirect them all, but this is how I had it set before in htaccess:

RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ index.php?tag=industry&slug=$1&id=$2

Which would give me something like:

site.com/industry/blah-blah.6842/

Now with my new site, I have the URLs set like this:

site.com/blah-blah/

So how I can do a 301 redirect in htaccess? I can't do all the articles individually because there's tons of them.

I need to be able to redirect this:

^industry/([a-zA-Z0-9-]+).([0-9]+)/$ to this: ^/([a-zA-Z0-9-]+)/$

Thanks in advance.

1条回答
姐就是有狂的资本
2楼-- · 2019-09-17 17:15

RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ /$1/ [R=301]

查看更多
登录 后发表回答