htaccess - 将博客移至子域

发布于 2024-09-14 12:48:50 字数 386 浏览 0 评论 0原文

我有一个博客,我将其移动到子域。由于 URL sintaxis 不会相同,我只想将 /posts/ 内的所有 url 请求重定向到新的子域:

from

domain.com/posts/xxxxx

to< /strong>

blog.domain.com

这是我到目前为止所拥有的,但它仍然必须仅过滤内部 /posts/ 的请求

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://blog.domain.com/ [R=301,L]

i have a blog, and im moving it to a subdomain. since the URL sintaxis won't be the same, i just want to redirect all url requests that are inside /posts/ to the new subdomain:

from

domain.com/posts/xxxxx

to

blog.domain.com

this is what i have so far, but it still has to filter only the requests that are inside /posts/

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://blog.domain.com/ [R=301,L]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

自此以后,行同陌路 2024-09-21 12:48:50

指令:

RewriteCond %{HTTP_HOST} ^domain.com
RewrietRule ^posts/(.*) http://blog.domain.com/ [R=301,L]

...应该有效。

The directives:

RewriteCond %{HTTP_HOST} ^domain.com
RewrietRule ^posts/(.*) http://blog.domain.com/ [R=301,L]

... should work.

能怎样 2024-09-21 12:48:50

你快到了。您只需修改它,以便 RewriteRule 中的正则表达式仅匹配 /posts/ 中的内容,如下所示:

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^posts/(.*) http://blog.domain.com/ [R=301,L]

You're almost there. You just need to modify it so that your regular expression in the RewriteRule only matches stuff inside /posts/ as below:

RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule ^posts/(.*) http://blog.domain.com/ [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文