htaccess 将文件夹重定向到新 URL
我有以下代码:
Redirect /email http://email.secureserver.net
这似乎不起作用。基本上,我需要能够在某人访问 www.thedomain.com/email/ 时将其重定向到 http://email。 secureserver.net
现在我希望它能够在我的测试服务器上运行,并且在它上线时也能运行,这样我就不必更改代码。
因此,对于测试,URL 将类似于:
www.testingserver.com/clients/drews-garage/live/email/
当它上线时,它将是:
www.thedomain.com/email/
因此,根据我上面提供的代码,无论哪种方式都应该有效,但它似乎在我的测试服务器上不起作用。我尝试了 301 重定向到。
有人有什么想法吗?
谢谢!
I have the following code:
Redirect /email http://email.secureserver.net
Which doesn't seem to be working. Basically, I need to be able to redirect someone when they go to www.thedomain.com/email/ to http://email.secureserver.net
Now I want this to be able to work on my testing server and also when it goes live so I don't have to change the code.
So for testing the URL will be something like:
www.testingserver.com/clients/drews-garage/live/email/
And for when it goes live it will be:
www.thedomain.com/email/
So based on the code I provided above, that should work either way but it doesn't seem to work on my testing server. I tried a 301 redirect to.
Anyone have any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议你使用
mod_rewrite
的RewriteRule
。而不是mod_alias
的redirect
。上面的内容将匹配 URI 路径中的
email/
。因此,clients/drews-garage/live/email/
以及email/
将被匹配。由于您的网址而无法正常工作:
www.testingserver.com/clients/drews-garage/live/email/
以上尝试重定向
www.testingserver.com/email/
或
mod_alias< /code> 可能无法加载。但是,
mod_alias
通常是默认加载的,因此这种情况不太可能发生。I suggest you to use
mod_rewrite
'sRewriteRule
. Rather thanmod_alias
'sredirect
.The above will match
email/
in your URI path. So,clients/drews-garage/live/email/
as well asemail/
will be matched.Is not working because of your URL:
www.testingserver.com/clients/drews-garage/live/email/
The above is trying to redirect
www.testingserver.com/email/
or
mod_alias
might not be loaded. But,mod_alias
is usually loaded by default so this case is very unlikely.