Apache的mod_rewrite域子域? [英] Apache mod_rewrite domain to subdomain?

查看:104
本文介绍了Apache的mod_rewrite域子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个地址 http://www.example.com 并在此页面的 http://www.example.com/world
我能做到这一点的mod_rewrite用,我的网页成为 http://world.example.com
任何一个环节,教程,...,将是很好,如果我能做到这一点?
而会是怎样与这些链接,例如:

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.

推荐答案

试试这个:

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

这篇关于Apache的mod_rewrite域子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆