301 redirect in htaccess

拟墨画扇 提交于 2020-01-16 19:25:09

问题


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:


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



来源:https://stackoverflow.com/questions/26119817/301-redirect-in-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!