我想从旧网站的光泽重新推出网站重定向一串网址。我的.htaccess正在与目录(即example.com/directory被重定向到example.com/newdirectory~~V)的第一级,但我有重定向下面的问题。这里有一个是不工作的例子:
I'm trying to redirect a bunch of URLs from an old site to the shiny relaunched site. My .htaccess is working with the first level of directories (i.e. example.com/directory is redirecting to example.com/newdirectory), but I'm having issues redirecting beneath that. Here's an example of one that's not working:
Redirect 301 /Expertise/QuantitativeResearch/ /services/quantitative-research/
此进到example.com/services/QuantitativeResearch - 这样的专业目录被重定向,但是URL的QuantitativeResearch部分不是
This goes to example.com/services/QuantitativeResearch - so the Expertise directory is being redirected, but the QuantitativeResearch part of the URL isn't.
我试图将其更改为RedirectMatch301,但它并不能帮助。我想知道如果我需要去掉/专业/,并使用一些正则表达式来代替?在/专业/一部分已经被重定向到/服务/由另一行:
I've tried changing it to RedirectMatch301, but it doesn't help. I'm wondering if I need to strip out /Expertise/ and use some Regex instead? The /Expertise/ part is already being redirected to /services/ by another line:
Redirect 301 /Expertise/ /services/
这会不会造成冲突?我知道我可能失去了一些东西很基本的在这里!只是为了澄清,我重定向都来了后RewriteEngine叙述上了。
Could this be causing conflict? I know I'm probably missing something really basic here! Just to clarify, my redirects are all coming after and before RewriteEngine On.
在此先感谢!
您确实需要在这里使用基于正则表达式匹配。尝试 RedirectMatch
来代替:
You do need to use regex based matching here. Try RedirectMatch
instead:
RedirectMatch 301 ^/Expertise/QuantitativeResearch/?$ /services/quantitative-research/
RedirectMatch 301 ^/Expertise/(.*)$ /services/$1