【问题标题】:.htaccess redirection of a subdomain to a domain, while keeping the links.htaccess 将子域重定向到域,同时保留链接
【发布时间】:2013-09-26 09:51:54
【问题描述】:

我有这个网址:

http://subdomain.maindomain.com

所有的链接都已经像这样共享了:

http://subdomain.maindomain.com/index.php?route=product/product&product_id=xxx
http://subdomain.maindomain.com/index.php?route=product/category&path=xxx
http://subdomain.maindomain.com/index.php?route=information/information&information_id=xxx

现在子域不再使用,所有内容都转移到主域中,所以我希望当有人点击其中一些链接时,打开的链接是这样的:

http://maindomain.com/index.php?route=product/product&product_id=xxx
http://maindomain.com/index.php?route=product/category&path=xxx
http://maindomain.com/index.php?route=information/information&information_id=xxx

即只有子域被重定向到域,但链接保持原样。有没有可能做到这一点?

谢谢。

【问题讨论】:

    标签: apache .htaccess redirect dns subdomain


    【解决方案1】:

    如果您的主域和子域在同一个根文件夹中,您可以使用:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^subdomain\.(maindomain\.com)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,QSA,L]
    

    否则你只需要:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^ http://maindomain.com%{REQUEST_URI} [R=301,QSA,L]
    

    【讨论】:

      猜你喜欢
      • 2014-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 1970-01-01
      • 2011-07-17
      • 2011-08-27
      相关资源
      最近更新 更多