htaccess 将文件夹重定向到新 URL

发布于 2025-01-07 23:07:33 字数 566 浏览 1 评论 0原文

我有以下代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬心 2025-01-14 23:07:33

我建议你使用mod_rewriteRewriteRule。而不是 mod_aliasredirect

RewriteCond %{Request_URI} /email/?$
RewriteRule ^ http://email.secureserver.net [L,R=301]

上面的内容将匹配 URI 路径中的 email/。因此,clients/drews-garage/live/email/ 以及 email/ 将被匹配。


Redirect /email http://email.secureserver.net

由于您的网址而无法正常工作:
www.testingserver.com/clients/drews-garage/live/email/

以上尝试重定向 www.testingserver.com/email/

mod_alias< /code> 可能无法加载。但是,mod_alias 通常是默认加载的,因此这种情况不太可能发生。

I suggest you to use mod_rewrite's RewriteRule. Rather than mod_alias's redirect.

RewriteCond %{Request_URI} /email/?$
RewriteRule ^ http://email.secureserver.net [L,R=301]

The above will match email/ in your URI path. So, clients/drews-garage/live/email/ as well as email/ will be matched.


Redirect /email http://email.secureserver.net

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文