问题描述
这是我的htaccess:
This is my htaccess:
## Rewrites
<IfModule mod_rewrite.c>
RewriteEngine On
Redirect /stream/ http://twitch.tv/8wayrun
Redirect /stream http://twitch.tv/8wayrun
RewriteCond %{HTTP_HOST} ^(www\.)?8wayrun\.com$
RewriteRule ^(.*)$ http://8wayrun.com/calibur/$1 [R=302,L]
</IfModule>
基本上,我需要将8wayrun.com/stream重写为twitch.tv/8wayrun ...
Basically, I need to to rewrite 8wayrun.com/stream to twitch.tv/8wayrun...
然后我需要它将8wayrun.com重写为8wayrun.com/calibur ...
And then I need it to rewrite 8wayrun.com to 8wayrun.com/calibur...
问题是,它将8wayrun.com/stream重写为8wayrun.com/calibur/stream。我该如何解决?
The problem is, its rewriting 8wayrun.com/stream to 8wayrun.com/calibur/stream. How do I fix this?
推荐答案
重定向
指令是其中的一部分mod_alias和 Rewrite *
指令是mod_rewrite的一部分。当通过URL /文件映射管道处理URI时,两个模块都将被应用,因此一个模块在另一个模块的前面无所谓,两个模块都将在最后应用。
The Redirect
directive is part of mod_alias, and the Rewrite*
directives are part of mod_rewrite. When a URI gets processed through the URL/file mapping pipeline, both modules get applied so having one in front of the other doesn't matter, both will get applied in the end.
最好只使用mod_rewrite并使用 L
标志来防止应用额外的重定向。
You're better off sticking with only mod_rewrite and using the L
flag to prevent the extra redirects from geting applied.
## Rewrites
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?stream/? http://twitch.tv/8wayrun [R=302,L]
RewriteCond %{HTTP_HOST} ^(www\.)?8wayrun\.com$
RewriteRule ^(.*)$ http://8wayrun.com/calibur/$1 [R=302,L]
</IfModule>
这篇关于htaccess在RewriteRule之前重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!