Apache mod_rewrite 域到子域?

发布于 2024-09-26 23:39:06 字数 645 浏览 0 评论 0原文

我有这个地址 http://www.example.com 并且有这个页面 http://www.example.com/world。 我可以使用 mod_rewrite 来做到这一点,使我的页面变成 http://world.example.com 吗? 任何链接,教程,...,会很好,如果我能做到这一点? 例如,这些链接会怎样:

  http://www.example.com/world/some-other-page
  http://www.example.com/world/and-second-apge

这些链接是否也会被重写为:

 http://world.example.com/some-other-page
 http://world.example.com/and-second-apge

另一个问题,这对 SEO 有好处吗?

我很抱歉我的英语不好。

I have this address http://www.example.com and have this page http://www.example.com/world.
Can I do this with mod_rewrite,to my page become http://world.example.com ?
Any link,tutorial,...,will be nice,if I can do this?
And what will be with these links for example:

  http://www.example.com/world/some-other-page
  http://www.example.com/world/and-second-apge

will these links also be rewritten to :

 http://world.example.com/some-other-page
 http://world.example.com/and-second-apge

Another question,is this good for SEO ?

I'm sorry on my bad English.

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

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

发布评论

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

评论(1

请帮我爱他 2024-10-03 23:39:06

试试这个:

RewriteEngine On

RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,NC]

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^world/([a-z0-9\-_\.]+)/?(.*)$ http://$1.domain.com/$2 [QSA,NC,R,L]

所以:

http://www.domain.com/world/page => http://world.domain.com/page

Try this:

RewriteEngine On

RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,NC]

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^world/([a-z0-9\-_\.]+)/?(.*)$ http://$1.domain.com/$2 [QSA,NC,R,L]

so:

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