我不是一个程序员,任何想象的延伸,我试图做多301重定向在我的基础上,下面的htaccess文件:
Hi I'm not a programmer by any stretch of the imagination and am trying to do a multi 301 redirect in my htaccess file based on the following:
所以,我有一吨的URL都具有类似的命名约定 - 这里是2的样品
So I have a ton of urls all with similar naming conventions - here is a sample of 2.
www.hollandsbrook/garrett-at-gold/ www.hollandsbrook/garrett-ace-250/这些网址需要重定向到:
These urls need to redirect to:
www.hollandsbrook/garrett-metal-detectors/garrett-at-gold/ www.hollandsbrook/garrett-metal-detectors/garrett-ace-250/
我可以重定向到1线的时间,但我想使用正则表达式。
I could just redirect them 1 line at a time, but I'd like to use regex.
下面是我在想什么,但她的不工作:
Here's what I was thinking so far but not working:
重写规则^加勒特 - ([AZ])/ $ /加勒特金属探测器/ $ 1 / [R]
RewriteRule ^garrett-([a-z])/$ /garrett-metal-detectors/$1/ [R]
基本上我需要重定向任何页面马上以garrett-开始,包括加勒特金属探测器的文件夹路径的根本。
Basically i need to redirect any page right off the root that starts with "garrett-" to include the folder path of "garrett-metal-detectors".
任何想法将非常AP preciated。提前感谢您的帮助。
Any thoughts would be MUCH appreciated. Many thanks in advance for your help.
推荐答案如果你想temprorary重定向使用:
if you want temprorary redirect use:
RewriteRule ^garrett\-([a-z0-9\-]+)/?$ /garrett-metal-detectors/garrett-$1/ [R=302,L]如果你想永久重定向使用:
if you want permanent redirect use:
RewriteRule ^garrett\-([a-z0-9\-]+)/?$ /garrett-metal-detectors/garrett-$1/ [R=301,L]更多推荐
htaccess的重定向子文件夹
发布评论