0

我很难得到

site.com/member-videos

进入

site.com/videos

或在现实中

#RewriteCond %{HTTP_HOST} !^/community/member-videos/
#RewriteRule (.*) http://site.com/community/videos/$1 [R=301,L]

这似乎循环!

对我来说,上面说找到'/community/member-videos/'的匹配项,然后将类似的内容发送到网址......我现在在这个典型的问题上浪费了太多时间,并且看了很多类似的在线,但没有什么很适合这种情况..谢谢

4

2 回答 2

0

You almost had it. The variable your condition matches against is a host, and not a URI. If you need to check the host, it must only be the hostname (not URI path at all), e.g. site.com. You need to use a %{REQUEST_URI} variable for what you are matching against:

RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/videos/
RewriteRule ^/?member-videos(.*)$ /videos$1 [L,R=301]

The example you gave doesn't have the community part in the URI at all, if it's not in the URL, it won't appear in the string sent to the rewrite engine. But your rules has /community in them, so if in fact you need that path, then:

RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/community/videos/
RewriteRule ^/?community/member-videos(.*)$ /community/videos$1 [L,R=301]
于 2012-10-30T18:34:07.877 回答
0
RewriteRule (.*) http://site.com/community/videos/$1 [R=301,L]

这是错误的,它会让你陷入无限循环。

试试这个:

RewriteRule http://site.com/community/member-videos/$1 ^community/videos/(.*)$ [R=301,L]
于 2012-10-30T15:56:38.023 回答