如何给一个子页它自己的域名? [英] How to give a subpage it's own domain name?

查看:297
本文介绍了如何给一个子页它自己的域名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Joomla网站 mysite.com

I have a Joomla site mysite.com.

我想有子页面 mysite.com/example 像使用独立域名的独立网站的行为 anothersite.com

I want to have the subpage mysite.com/example act like a separate website using a separate domain name anothersite.com.

可以这样使用的域和htaccess的DNS设置,可以实现?

Can this be achieved using DNS settings on the domain and htaccess?

主办的网站在cloudaccess.net但希望这种解决方案的单页网站和登陆页面,而无需使用完全是另外一个托管帐户/的Joomla实例。

Hosting sites at cloudaccess.net but want this solution for one-page sites and landing pages without using a whole other hosting account / joomla instance.

感谢。

推荐答案

如果您的托管服务提供商可以让你有别名域,可以指向现有的code中的新领域,并使用检测的主机名的RewriteCond

If your hosting provider allows you to have "alias" domains, you can point the new domain at the existing code, and detect the hostname using RewriteCond:

  1. 在首先配置的新域名,以​​显示所有相同的内容作为现有域。
  2. 在Apache的配置(可能是的.htaccess 的共享主机)添加规则,其检测要求为新域,和重写他们,而不是服务您指定页:

  1. Start by configuring the new domain to display all the same content as the existing domain.
  2. In the Apache configuration (probably .htaccess on shared hosting) add a rule which detects requests for the new domain, and "rewrites" them to instead serve your specific page:

RewriteCond %{HTTP_HOST} landingpage.example.com
RewriteRule ^/$ /url/for/my/landing/page

  • 添加其他规则的之后的,以便在该领域其他的URL重定向浏览器回主网站

  • Add an additional rule afterwards so that other URLs on that domain redirect the browser back to the main site

    RewriteCond %{HTTP_HOST} landingpage.example.com
    RewriteRule ^/([^/].*)$ http://realsite.example.com/$1 [R=permanent,L]
    

  • 这方面的一个变体将是一切对第二域映射到一个目录(或者说,一个URL preFIX)中的第一个域,通过结合这两个规则:

    A variation of this would be to map everything on the second domain to a directory (or, rather, a URL prefix) in the first domain, by combining those two rules:

    RewriteCond %{HTTP_HOST} subsite.example.com
    RewriteRule ^/(.*)$ /url/for/my/subsite/$1 [L]
    

    注意:如果的Joomla认为它知道正确的URL页面时,它可能会尝试重定向远离您的新域名。如果是这样,这是一个新问题的话题。

    Note: If Joomla thinks it knows the "correct" URL for the page, it may try to redirect away from your new domain. If so, that is the topic for a new question.

    如果,在另一方面,你要使用Apache配置强制用户访问 http://realsite.example.com/url/for/my/landing/page 被重定向到 http://landingpage.example.com/ ,你可以添加这样的事情:

    If, on the other hand, you want to use Apache configuration to force users accessing http://realsite.example.com/url/for/my/landing/page to be redirected to http://landingpage.example.com/, you could add something like this:

    RewriteRule ^/url/for/my/landing/page$ http://landingpage.example.com/ [L,R=permanent]
    

    注意:根据某些环境设置,我不完全了解,您可能需要更改 ^ / 只是 ^ 在上面的图案。

    Note: Depending on some environment settings I don't fully understand, you may need to change ^/ to just ^ in the patterns above.

    这篇关于如何给一个子页它自己的域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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